Thursday, April 24, 2014

Unlock files and folders using Process Explorer

Ever tried renaming\moving\deleting a file or folder and got this error?

The action can't be performed because the folder or a file in it is open in another program. Close the folder or file and try again.
Or, in case of a file:
The action can't be performed because the file is open in <Application Name>.
In my case, I've set up a shared folder for a virtual machine (VMware Workstation 10) and opened a file from it in a virtual machine. I have already closed the file, but it still was locked for renaming by the VMware.

So how do you deal with it?
Here is a stupid and careless method. Go download "Unlocker" software and use it. The software is long not supported and I wouldn't risk using it on modern OS. Besides, it requires installation. I am not going to provide any download links, because I don't encourage using it. It is like a hammer, while the solution I suggest is like a scalpel.

What I do suggest, is downloading a Process Explorer tool from SysInternals. Among other ton of features, it allows terminating a single handle in a process that locked the file, and searching for it.

Here is the download link:

So what do you need to do with it? First - download, unpack, run and agree with EULA.

Then, press on the binocular icon (or use hotkey: CTRL+F) and type in the path to the folder or file that is locked and click the Search button. Any path substring will also do, but the more precise you are, the less results you'll get.

Highlight the handle that opened the file. The best and safest way, of course, would be to shut down the program that has this handle. But I don't want to shut down a virtual machine, that takes damn lot of time to turn it back on! Besides, a file can be locked by some system process that you can't safely shut down.

So what you can do, is highlight the handle, then close the search box, and in the main window the handle will still be highlighted. Right click on it and select Close Handle.

That should help. There also theoretically may be multiple handles locking a directory or a file - in this case you will need to repeat the procedure.

Hope it helps. Questions are welcome in the comments ;)

P.S. a colleague pointed me to a command line tool that can do the job. It is also made by SysInternals and is called "Handle". You can download it here:

Monday, August 19, 2013

Automatic whole number sequences in PowerShell

Try this:

 5..15 | ForEach {Write-Host $_}

That's a very interesting way to make some whole number sequences.

It also works in reverse and with negative numbers, i.e. 10..-5 | ForEach {Write-Host $_}

Monday, June 24, 2013

XnView not opening? (solution inside)

I love the XnView image viewer. It is fast and simple, navigation is easy and it has handy hotkeys for rotate\resize\crop\save(as) functions (the only editing functions I require from an image viewer)

One day the XnView stopped opening :(

Either if I opened XnView from Start Menu or if I opened an image with it - XnView program just appeared in the taskbar but the actual window never appeared :(. I even reinstalled it but no luck, it still wasn't opening.

Here is what I did to fix this:

I went to the C:\Users\ubeogesh\AppData\Roaming\XnView (ubeogesh is the username) folder and deleted the XnView.ini file and that fixed the problem. It may be that some setting inside the XnView was corrupt, but I don't really care. The few settings I use are quite easy to reconfigure rather then digging inside that INI file.

Note that this works only if you choose the default option when starting XnView (store XnView settings in INI file per-user)

Logitech G500 not detected? (solution inside)

I was installing Logitech Gaming Software for my G500 mouse, and the Gaming software kept showing the  "No devices detected" message:

So I looked up in the device manager and checked the mouse driver - it was showing "HID-compliant mouse". I expected after installation it to show something like "Logitech G500 Mouse"...

So then I looked up the folder where Logitech Gaming Software was installed (C:\Program Files\Logitech Gaming Software by default) and there was a folder "Drivers"!

Great, I've selected the "HID-compliant mouse" and opened "Update Driver Software..." from the context menu. There you go to "Browse my computer for driver software" and choose the folder with Logitech drivers:
Press Next and the wizard will tell you that it installed the "Logitech HID-compliant G500 Gaming Mouse" :)

Open up the Logitech Gaming Software and the G500 will be detected :)

Tuesday, May 21, 2013

How to generate many GUIDs using PowerShell

Use this simple PowerShell script:

$i = 1
do {
    $guidObject = [System.Guid]::NewGuid()
    Write-Output $guidObject.Guid >>c:\1.csv
    $i++ }
while ($i -le 1000)

Save the code above to a file with .ps1 extension, right click on it -> Run with PowerShell. 1000 random the GUIDs will be written to a file named C:\1.csv

To run PowerShell scripts, you need to configure PowerShell to allow them. Run in PowerShell:

Set-ExecutionPolicy -ExecutionPolicy Unrestricted

When prompted, type Y and press enter.

Friday, April 26, 2013

How to add bookmarks in steam overlay UI

Yes! You can do that! You can add bookmarks to steam overlay UI, so you can one-click open them in browser in-game. This is not super easy, but not hard at all

What do you need:
1) Page URL
2) Text editor

How to do that:

1) Open your steam folder, navigate to \resource\layout\ folder
2) Find overlaydesktop.layout file and open it with any text editor. The file format is similar to JSON.
3) In the text editor, in "controls" section, add following line:
BookmarkID { controlname="URLLabel" labeltext="Your bookmark name here" urltext="your page URL here" style="sidemenu"}

Creating a new control in steam overlay

BookmarkID is something that you will refer this bookmark in next step
4) In "layout" section, add your BookmarkID to the list in following line:
place { controls="GameGroupsButton,ChatRoomButton,DLCButton,GuideButton,LegacyCDKeyButton,WebSiteButton,RecommendButton,WorkshopButton" y=50 align=right region=overlay dir=down spacing=10 }

Adding a link to steam overlay layout

5) Save the file and you're done!
Here is how it looks: