![]() |
Rename command fails although there's no lock
Hi,
I noticed a while ago that in case I am trying to rename a folder that is currently open in Windows Explorer, the operation sometimes fails. In order to try and figure out what is happening, I created a small script that uses the LockesList plugin (to see if anything is really locked): code: I also have the following folder structure: \Original \config I then execute LockedList.exe in different scenarios.\test.txt
Here are the results: Case 1: LockedList returns "next" as no locks found, folder is renamed Case 2: LockedList returns "next" as no locks found, folder is renamed Case 3: LockedList displays Notepad.exe as a lock. I close it and it then returns "next". Rename failes (as folder Original\config displayed in Windows Explorer - since I opened the txt file) Case 4: LockedList returns "next" as no locks found, rename failes. Now I found this a bit "weird". Rename works ok if only the folder to be renamed is displayed in Windows Explorer but fails as soon as any subfolders thereof are displayed. Also, LockedList finds no locks and manual renaming also works. Any idea why this might happen? Thanks, Mircea |
I think Explorer might be using oplocks (opportunistic lock) (if they are supported on directories) and I'm not sure if LockedList supports those.
Have you tried calling AddFolder for all subfolders? (I don't think this should be necessary but maybe the plugin has a bug?) |
Hi,
yes, I tried that too but it doesn't change anything. So, do you know of any way to Rename / Move such folders? My idea was to "kill" all Windows Explorer processes before performing the move, just to be sure, but this is not an elegant solution... |
You might want to report it as a bug in the plugin...
|
Hi Anders,
ok, will do that but the problem isn't actually with the plugin, I believe. As far as I can tell, the plugin does find the locks when the files are actually "really" locked. Since at the time when my test installer says it can not rename the folder, by using any other methods, it is actually possible to perform the operation, I would think there's an issue with NSIS maybe. Mircea |
Quote:
|
Years ago I added a native program to do this for me which has proven reliable ever since
// chkfolder.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include "windows.h" #define MAXPATH 1024 int result=0; // 0 = good - folder renames worked, not zero = bad - folder rename failed wchar_t buf[MAXPATH]; // maxpath int _tmain(int argc, _TCHAR* argv[]) { // argv[1] = product folder if (wcsnlen(argv[1], MAXPATH) > 0) { HWND hWnd = GetConsoleWindow(); ShowWindow(hWnd, SW_HIDE); result = _wrename(argv[1], argv[2]); } else { wprintf(L"product folder name must be at least one character in length."); } return result; } |
Quote:
Also, why would you use a console program if you just try to hide the console window anyway, it is going to flash up on the screen for a second. |
| All times are GMT. The time now is 17:21. |
Copyright © 1999 - 2010 Nullsoft. All Rights Reserved.