Sign in to follow this  
Followers 0
willywill

Proc close function

4 posts in this topic

Hi all,

I have an exe file that's loaded in the start-up directory. It runs after my WinXP image is deployed to perform steps such as renaming the hostname, etc. The last step is to remove the image.exe from the start-up directory, so that it won't run again. The problem I'm facing is that I cannot remove the file until the proc has stopped. How would I approach this issue? If I run ProcessClose, then I'm effectively killing it, so it won't be able to remove the image.exe from the startup directory.

Looking for suggestions.

Thanks!

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Deploy the actual exe somewhere else and work with shortcuts... this is how I do it in SMF...

; Create
FileCreateShortcut(@ScriptDir & "\SMF.exe", @StartupDir & "\SMF - Search my Files.lnk", @ScriptDir, "", "SMF Autostart Link", @ScriptDir & "\SMF.exe", "", "0", @SW_MINIMIZE)

; Remove
´FileDelete(@StartupDir & "\SMF - Search my Files.lnk")
Edited by KaFu

Share this post


Link to post
Share on other sites

you want to delete your scripte?

Have a look at this _SelfDelete() function. Basically creates a batch file that deletes the script, then deletes itself.

http://www.autoitscript.com/forum/index.php?showtopic=91187&view=findpost&p=655966

Func _SelfDelete($iDelay = 0)
    Local $sCmdFile
    FileDelete(@TempDir & "\scratch.bat")
    $sCmdFile = 'ping -n ' & $iDelay & '127.0.0.1 > nul' & @CRLF _
            & ':loop' & @CRLF _
            & 'del "' & @ScriptFullPath & '"' & @CRLF _
            & 'if exist "' & @ScriptFullPath & '" goto loop' & @CRLF _
            & 'del ' & @TempDir & '\scratch.bat'
    FileWrite(@TempDir & "\scratch.bat", $sCmdFile)
    Run(@TempDir & "\scratch.bat", @TempDir, @SW_HIDE)
EndFunc

Share this post


Link to post
Share on other sites

Actually having thought about it, I'm going to the executable in it's current location, and just link to it, per Kafu's suggestion. I like to simplify it as much as possible, so that the next person doesn't spend too much time troubleshooting what I did.

Thanks for your help! I just finished my very first script successfully!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0