Excel generating several .xar files upon computer restart - windows-7

My computer has an update process that auto-restarts it around 3 am. Sometimes, upon restart, a number of .xar files are generated which Excel tries & fails to open, preventing it from executing automated processes I've set up for the morning.
How do I prevent the .xar files from being generated?

.xar files are Auto recovery files, probably created because your restart doesn't gracefully exit Excel.
You can disable auto recover on a workbook by going to the office button, excel options, save, AutoRecover exceptions for: and then checking "Disable AutoRecover for this workbook only".
If you do this for the workbooks that you're update process uses it should prevent the failure you're experiencing.

Related

Run macro from desktop, hidden & with minimum system impact

Recently the IT policy at my work changed, and all scripts I have been using (.bat .cmd .py) no longer work. Where possible I have converted these to VBA macros that run in workbooks - as these are still enabled.
Here are two macros to schedule a force shutdown/ cancel it (respectively)
Private Sub Workbook_Open()
Application.Visible = False
Shell "SHUTDOWN /s /f" '/Scheduled shut down, /Forced (ignores any unsaved)
End Sub
And in a 2nd workbook
Private Sub Workbook_Open()
Application.Visible = False
Shell "shutdown /a" '/Abort scheduled shutdown
Application.Quit
End Sub
As you can see the macros run on Workbook_Open() events, with Application.Visible = False. The intent is for a desktop shortcut to open these workbooks as invisibly and quickly as possible.
Issues & solutions
It's slower - I used to run this as a batch script, now Excel has to open to run it
I've made it an .xlsb to reduce opening time, is there a faster method?
I'm not asking how to speed up my workbook, I just mean is there a different way of saving the file (an addin perhaps?) which can run without Excel opening?
I've also only chosen to close Excel when shutdown is aborted, not when it is scheduled, as if Excel is already open then the cancel macro opens faster (which is essential if I accidentally schedule shutdown)
The running is not invisible; although the workbook itself is never shown, the Excel startup image appears
I have tried adding switches to the shortcut target (/e to prevent standard template loading /r for readonly in the hope that it wouldn't display the sheet) - but they don't work
"C:\Program Files (x86)\Microsoft Office\root\Office16\EXCEL.EXE" /r /e "C:\Users\USERNAME\Documents\start.xlsb"
The Application calls are Excel-wide. Sometimes, I schedule a shutdown before I've saved everything. (I know it will take me a few seconds to save so I schedule shutdown first)
That was fine when I ran these as .bat/.cmd scripts, but if I run these and Excel is open then everything closes (or becomes invisible - although I have no way of checking which one), which is not ideal when I'm still working on something.
Can I make sure these only hide themeselves? Would opening another instance of Excel help?
TL;DR
I've saved macros as Workbook_Open() events in .xlsb workbooks, which run from desktop shortcuts
How can I improve on this in
Making the process hidden
Making the process faster
Preventing the process screwing up the rest of Excel
By
Flags in the desktop shortcut
Changes to the macro code
Changing how the macro is saved
And
Without just converting to scripts as they are blocked
NB, I would do this with VBS to circumvent Excel entirely, but that is blocked too
Fastest is a desktop shortcut with the shutdown command, i.e. %WINDIR%\system32\shutdown.exe /s /f

Locked excel sheet that isn't open

I am trying to open a locked excel sheet. The warning says it is locked because it is being used by "AN Other".
This person does not have the sheet open, does not have any excel applications open, does not have any excel based tasks running in the task list and has tried the good old "turning it off and on again".
Neither of us can save onto this filename, change it in windows explorer or delete the file.
We have "saved as" another name but really need the original name. I looked at a few forums and they suggest this is an excel/windows bug.
Am using excel 2010 and Windows 7.
You need to get in touch with your IT support.
In a company network, a file will be locked for other users when somebody edits it. It can happen sometimes that the file does not get released (unlocked) when the user closes it. Your IT Support people need to unlock the file, so you can edit it again.

PhpStorm 5 saving watches and a single file

I have two questions on PhpStorm 5.
1) Can Watches be saved along with a debug configuration, so I don't have to re-create them every time I close and re-open the software? I have noticed that watches may be deleted by the software even during a working session.
2) Is there a way to save just a single file instead of saving all of the open files (only 'Save All' function exists).
1. Unfortunately No. Watches got deleted as soon as debug tool window is closed.
Corresponding ticket: http://youtrack.jetbrains.com/issue/IDEA-42954
UPDATE: Yes, this is now possible as of version 10 or so -- the aforementioned ticket has been implemented so all watches are now saved together with Run/Debug Configuration that was used to launch the debug.
2. Yes, you can -- but only since PhpStorm v7. But that still makes little to no difference as all other files will be saved anyway on standard occasion (change setting; run/re-run something etc -- same logic as before -- you cannot close editor tab and reject all changes automatically or be asked if file must be saved or not).
More details in this SO answer: https://stackoverflow.com/a/19147691/783119

the action can't be completed because the folder or a file in it is open in another program

When deleting a folder that contains a file that is in use, it is common to see the following Windows 7 message,
"The action can't be completed because the folder or a file in it is open in another program."
I commonly have 10-20 programs open, 30-40 folders open, etc. In short, I have many executables running and many windows explorers open.
Does anyone know a simple trick to determine which program is using the file?
Does anyone know a simple trick to determine which file is blocking the delete operation?
This information would be highly useful to display in the Windows 7 'folder in use' dialog, but it is missing.
Consequently I have to close many of my open applications and folders to complete the delete operation. This is annoying because I have to re-open them after deleting them.
Have you seen this other question or this one?
I use to run ProccessExplorer and Find for the blocked folder.
Closing the application Malwarebytes allowed me to delete what I needed to via Windows Explorer.

Releasing Windows file share locks

This problem crops up every now and then at work. Our build machine can have it's files accessed via a normal windows file share. If someone browses a folder remotely on the machine, and leaves the window open overnight, then the build fails (as it has done now). The explorer window left opened points at one of the sub folders in the source tree. The build deletes the source, and does a clean checkout before building. The delete is failing.
Right now, I'd like to get the build to work. I'm logged in from home, and I'd rather not reboot the build machine. I'm unable to get hold of the person whose machine is looking and the files, and I can't remotely reboot their machine.
When a windows share has a lock, the locking process is System, so I don't think I can kill it, as with normal locks.
Does anyone know a way to release the lock on a shared folder without having to reboot the machine?
If you are admin on the server sharing the file over the network, you can use the Windows in-built feature:
Start → My Computer → Right-click → Manage gets you to the Computer
Management console
In the left nav, navigate to Systems Tools → Shared Folders
You can view Shares, Sessions & Open Files here. This allows you to find out who has opened which files from which workstations.
Right-click on an item in the list to be able to remove the file lock.
Hope this helps.
Found a solution.
Find the process using Process Explorer:
Download and extract procexp.exe
In Process Explorer use the "Find Handle or DLL..." command from the "Find" menu
Enter in the name of the directory which is having trouble deleting
A list of open files which match that name should be shown. Take some guesses and find which one is failing to be deleted. If the file is locked by a windows share, the process holding the file will be System
Note down the directory which was left open
Download and install the Unlocker (Warning: Link removed, as it contains malware)
Install Unlocker, disabling the option for Explorer extensions and other junk
Unlock the directory
Open up a cmd window, and navigate to C:\Program Files\Unlocker
From the cmd window, run Unlocker.exe "the-path-to-the-locked-folder"
A dialog will pop up confirming the lock release. Use the unlock button to unlock the file
Now the directory should be unlocked, and can now be deleted.
Try Process Hacker:
https://wj32.org/processhacker/
Process hacker is like Process Explorer on steroids.
To find the offending process, press CTRL+F or click the "Find Handles of DLLs" button and search for the file name.
Once you find the file in the find handles dialog, you can simply right click the file there and choose "close". (at least for v2.39.124)
Older versions had a "terminator" option in the context menu of the process.
Right click on the offending process --> Miscellaneous --> Terminator --> Select termination techniques. Note that some are possibly dangerous and may have unintended consequences.
I've had similar problems, and none of these suggestions I've seen above look suitable for automated overnight builds (as the original poster implied) because they all require manual effort to hunt down and kill the locks.
The only method I've tried that seems to work reliably is to remove the share itself, make the build, then add the share back. Here's one way of removing the share automatically:
D:\Projects>net share Projects /DELETE /Y
Users have open files on Projects. Continuing the operation will force the files closed.
Projects was deleted successfully.
(NOTE: Creating the share again automatically can be a pain if the privilege groups you need to give it are messy.)
The way i do it is by using both OpenFiles.exe and Handle.exe
You can run them in any order and you will have your resource fully unlocked.
OpenFiles: to disconnect File Sharing sessions
Handle.exe: to release any open handles (don't try to close handles belonging to pid4, since that's the system process)
You can automate this by using powershell, batch, or any language of your choice.
Another option is, starting from Windows Vista, to use the Windows tool built into the system:
monitor resources: perfmon.exe /res
Extracted from: Http://www.sysadmit.com/2017/06/windows-how-to-know-that-process-has-open-a-file.html

Resources