willywill Posted October 19, 2009 Share Posted October 19, 2009 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! Link to comment Share on other sites More sharing options...
KaFu Posted October 19, 2009 Share Posted October 19, 2009 (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 October 19, 2009 by KaFu OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
TurionAltec Posted October 19, 2009 Share Posted October 19, 2009 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 Link to comment Share on other sites More sharing options...
willywill Posted October 19, 2009 Author Share Posted October 19, 2009 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! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now