AutoHotkey Community

It is currently May 27th, 2012, 8:41 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: Replace Active File
PostPosted: May 5th, 2006, 7:40 pm 
Offline

Joined: October 28th, 2005, 1:26 am
Posts: 113
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 :oops:

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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 5th, 2006, 8:53 pm 
Offline

Joined: September 2nd, 2004, 1:08 am
Posts: 124
Location: Sunnyvale
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.as ... -us;140570

_________________
I am he of whom he speaks!


Last edited by Atomhrt on May 5th, 2006, 11:50 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 5th, 2006, 9:19 pm 
Offline

Joined: November 15th, 2005, 11:15 am
Posts: 537
Location: Germany
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Re: Replace Active File
PostPosted: May 6th, 2006, 1:21 am 
Offline

Joined: September 20th, 2005, 9:23 pm
Posts: 16
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 :oops:

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. :D

_________________
-Lufia


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 6th, 2006, 7:23 am 
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.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: May 7th, 2006, 1:23 am 
Offline

Joined: October 28th, 2005, 1:26 am
Posts: 113
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!! :D What a great and simple idea...

I'll give that a shot. Thanks for the idea.

Gary


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Re: Replace Active File
PostPosted: May 7th, 2006, 4:56 am 
Offline
User avatar

Joined: December 29th, 2004, 1:28 pm
Posts: 2545
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 9th, 2006, 4:47 pm 
Offline

Joined: October 28th, 2005, 1:26 am
Posts: 113
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 9th, 2006, 5:24 pm 
Offline

Joined: October 28th, 2005, 1:26 am
Posts: 113
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! :idea: 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


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Exabot [Bot], specter333, XstatyK and 57 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group