Find out which process is locking a file or folder in Windows

For Windows 7, 8 and 10 you can use the built-in Resource Monitor for this.

  1. Open Resource Monitor, which can be found by searching for resmon.exe in the start menu, or as a button on the Performance tab in your Task Manager.

  2. Use the search field in the Associated Handles section on the CPU tab
    pointed at by blue arrow in screen shot below.

In case it’s not obvious, when you’ve found the handle, you can identify the process by looking at the Image and/or PID column.

You can then close the application if you are able to do that, or just right-click the row and you’ll get the option of killing the process right there. Easy peasy!

Remark: The complete text and the picture above are taken from one of the answers to the question on superuser.com.
Some of the comments there claim that sometimes they could not find handles with Resmon but could find them with Process Explorer. Some others claim they could not find handles with Process Explorer but with Resmon.

I’d like to add, if you are looking for the directory C:\alpha\beta\gamma, you can enter in the search field
* gamma or GAMMA or \Gamma
* beta\gamma
* beta or \beta\
* C:\alpha\beta\gamma
* You cannot use slashes instead of backslashes.

How to Do a Real Windows 10 Restart

To my astonishment, Windows 10 does not really do a full restart or shutdown when you select the according menu entries from the start menu.

This is bad, because if you want to do a restart, you want to do this because something is wrong with the system. So then a partial restart is exactly not what you usually want.

You still can do a real restart via commandline:

%windir%\System32\shutdown.exe /r /t 0

When you rightclick on the desktop and select New/Shortcut and put in the commandline above you create an icon on the desktop with which to do a real restart.
Also, it may be good for the system to do a real shutdown once a week. Here’s the commandline.

%windir%\System32\shutdown.exe /s /t 0

MS Access UPDATE with JOIN

I’m forced to use MS Access for some legacy system. I don’t know what Microsoft thought when they made it so that MS Access uses a flavor of SQL that’s pretty different from their main product SQL Server. Did they just think nothing or is there some evil intent? Nothing probably. But anyhow, they did it.

In this post, I describe how to do a UPDATE with JOIN query in MS Access.

I want to replicate the following SQL Server query (in TSQL) in MS Access.

-- MSSQL
UPDATE Sachwert SET Wert = '1', DATE = GETDATE()
    FROM Artikel a
    INNER JOIN Sachwert AS s on a.GUID = s.GUID
    INNER JOIN Sgpos AS sgp on sgp.SACHGRUPPE = s.SACHGRUPPE 
    INNER JOIN Catalog c on c.Year = a.Year 
    WHERE a.Artikel = '104905' AND sgp.SACHGRUPPE = 'V1'

For MS Access you have to do these changes:

  1. Put the name of the table where the update should happen before each name of each column which you want to change and remove the name of the table which is located before the SET. This gives
    UPDATE SET Sachwert.Wert='1', Sachwert.DATE = GETDATE().
  2. Put the SET clause after the JOINs, remove the word FROM but leave the word UPDATE at the beginning.
  3. If you have defined an alias, you must use this alias in the rest of the query. You then cannot longer use the original name. In our case, the SET clause must change to SET s.Wert='1', s.DATE = GETDATE() because of the Sachwert AS s.
  4. If you have N JOINs, you have to add N-1 sets of parentheses. The left parentheses must all be directly after the UPDATE, the right ones one after each JOIN-clause – except the last one.
  5. GETDATE() is called NOW() in Access.

So in the end you get this:

-- MS Access
UPDATE 
       ((Artikel a
          INNER JOIN Sachwert AS s on a.GUID = s.GUID)
          INNER JOIN Sgpos AS sgp on sgp.SACHGRUPPE = s.SACHGRUPPE)
          INNER JOIN Catalog c on c.Year = a.Year 
       SET s.Wert = '1', s.DATE = NOW()
       WHERE a.Artikel = '104905' AND sgp.SACHGRUPPE = 'V1'