| View previous topic :: View next topic |
| Author |
Message |
JeremysDad
Joined: 28 Oct 2005 Posts: 102
|
Posted: Fri May 05, 2006 7:40 pm Post subject: Replace Active File |
|
|
Hey guys,
I have created a series of scripts about 30 people in our office and have just run into a problem my amateur programmers brain didn't prepare for
The scripts are all loaded in a shared drive with the AHK executable. In the morning, the users activate the main script via an icon on their quick launch bar and then access the scripts through a menu activated by the mouse wheel.
I want to upgrade to the latest version of AHK but of course when I try to do so, I get an error from Win2K that the file is in use.
Short of running around the office and trying to get everyone to log out for a few minutes, is there another approach?
I've searched the forums using "Delete + Open" with no success. Any help would be appreciated.
Gary |
|
| Back to top |
|
 |
Atomhrt
Joined: 02 Sep 2004 Posts: 128 Location: Sunnyvale
|
Posted: Fri May 05, 2006 8:53 pm Post subject: |
|
|
One way to do it is to use the API MoveFileEX call.
Win32-based applications running on Windows NT should use MoveFileEx() with the MOVEFILE_DELAY_UNTIL_REBOOT flag to move, replace, or delete files and directories currently being used. The next time the system is rebooted, the Windows NT bootup program will move, replace, or delete the specified files and directories.
http://support.microsoft.com/default.aspx?scid=kb;en-us;140570 _________________ I am he of whom he speaks!
Last edited by Atomhrt on Fri May 05, 2006 11:50 pm; edited 1 time in total |
|
| Back to top |
|
 |
Micha
Joined: 15 Nov 2005 Posts: 436 Location: Germany
|
Posted: Fri May 05, 2006 9:19 pm Post subject: |
|
|
Hi, I've posted that related at another thread:
| Quote: | Hi,
I have the same problem.
On our network I'm not able to delete/replace files which are locked / in use by another person, but I'm able to rename them. Funny, but true.
I had to replace more folders at once. Therefore I rename the folders to the current date "2delete_12042006" and copy the new folder (with the old name) to the network. After a while (with the next update/next day) I'm able to kill the temporary folder, because everybody is using the new/current folder.
Ciao
Micha |
You can try it: Try to rename the whole folder while other people have the files locked. If it works, you have a simple solution
Ciao
Micha |
|
| Back to top |
|
 |
Lufia
Joined: 20 Sep 2005 Posts: 16
|
Posted: Sat May 06, 2006 1:21 am Post subject: Re: Replace Active File |
|
|
| JeremysDad wrote: | Hey guys,
I have created a series of scripts about 30 people in our office and have just run into a problem my amateur programmers brain didn't prepare for
The scripts are all loaded in a shared drive with the AHK executable. In the morning, the users activate the main script via an icon on their quick launch bar and then access the scripts through a menu activated by the mouse wheel.
I want to upgrade to the latest version of AHK but of course when I try to do so, I get an error from Win2K that the file is in use.
Short of running around the office and trying to get everyone to log out for a few minutes, is there another approach?
I've searched the forums using "Delete + Open" with no success. Any help would be appreciated.
Gary |
I do something similar to this at work. A good idea that I use in my scripts that are run globally is putting a simple line in the script near the beginning like
| Code: |
IfExist, Exit.txt
{
ExitApp
}
|
This way you can just create an empty Exit.txt file out there and it will close on all the PCs giving you enough time to update the executable and delete Exit.txt. Edit: You can also put a msgbox command or something in here saying that the program is being updated and to try again in a few minutes.
If you have administrative rights to the network then you should be able to use a command line tool such as psexec or pskill (pskill needs to be loaded in the users system32 folder I believe for Windows which you could copy there with a script that users run or using login script). With pskill you can close processes out on remote PCs. Also if you have access to the server, you can close out open files by right clicking My Computer, clicking Manage, Shared Folders, Open Files and close out all of the users from the file that way.
Hopefully one of these works for you.  _________________ -Lufia |
|
| Back to top |
|
 |
BoBo Guest
|
Posted: Sat May 06, 2006 7:23 am Post subject: |
|
|
| Quote: | | Short of running around the office and trying to get everyone to log out for a few minutes, is there another approach? | Do your updates at nighttime (WOL), lunchtime (user driven), at their login (via loginscript) and don't miss to log which boxes have been updated successfully! You can use [sysinternals] BGInfo to do pre/post inventory scans. |
|
| Back to top |
|
 |
JeremysDad
Joined: 28 Oct 2005 Posts: 102
|
Posted: Sun May 07, 2006 1:23 am Post subject: |
|
|
Lufia,
| Quote: | | I do something similar to this at work. A good idea that I use in my scripts that are run globally is putting a simple line in the script near the beginning like |
I absolutely love it!! What a great and simple idea...
I'll give that a shot. Thanks for the idea.
Gary |
|
| Back to top |
|
 |
corrupt
Joined: 29 Dec 2004 Posts: 2393
|
Posted: Sun May 07, 2006 4:56 am Post subject: Re: Replace Active File |
|
|
| JeremysDad wrote: | | The scripts are all loaded in a shared drive with the AHK executable. In the morning, the users activate the main script via an icon on their quick launch bar and then access the scripts through a menu activated by the mouse wheel. |
I would suggest not doing things that way. Instead of sharing one AHK executable you could leave the executable in place on the shared drive but have the users copy the file to another directory during login (using a small batch file or script(compiled) in their startup folder or in the registry: HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run or HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run or another method if you prefer...) and have them launch their scripts using the copy of the AHK executable instead. This way they will get the latest version each time they login and you will be able to update the main executable on the share since it will not be in use.
One issue that you may eventually run into with the method that you're attempting is that a script may be forced to terminate on a user's machine while in use and cause data loss and/or undesireable results. If the .exe gets updated during login then the scripts that are running can continue to run. |
|
| Back to top |
|
 |
JeremysDad
Joined: 28 Oct 2005 Posts: 102
|
Posted: Tue May 09, 2006 4:47 pm Post subject: |
|
|
Corrupt,
| Quote: | | Instead of sharing one AHK executable you could leave the executable in place on the shared drive but have the users copy the file to another directory during login (using a small batch file or script(compiled) in their startup folder or in the registry: |
Ahh, the subtleties become apparent
So I've started to work on your idea. The only thing I'm not sure of is how to get AHK to recognize the script I wrote. As written right now, it tries to create a default script rather than using mine.
| Code: | IfNotExist, h:\CopyDir\
FileCreateDir, h:\CopyDir
FileCopy, S:\Tools\AutoHotKey.exe, h:\CopyDir\, 1
FileCopy, S:\Tools\AutoHotKey.ini, h:\CopyDir\, 1
Run, h:\NotesToolSDMT\AutoHotKey.exe, MyScript.ahk |
Any ideas?
Thanks
Gary |
|
| Back to top |
|
 |
JeremysDad
Joined: 28 Oct 2005 Posts: 102
|
Posted: Tue May 09, 2006 5:24 pm Post subject: |
|
|
| Quote: | | So I've started to work on your idea. The only thing I'm not sure of is how to get AHK to recognize the script I wrote. As written right now, it tries to create a default script rather than using mine. |
AHA! I found the SetWorkingDir command and that did the trick. I'll keep playing with this and see how close I can get to Corrupt's suggestion.
Thanks All!
Gary |
|
| Back to top |
|
 |
|