nitr0 Posted November 5, 2008 Posted November 5, 2008 (edited) Im new to the world of scripting and im fighting for almost 3 days to get this to work... I searched this forum like crazy, been viewing examples etc but I can't find anything usefull, so I desided to plant the question in the forum. I am trying to make my script "test.exe" to copy itself upon execute to a temp folder, and then execute itself from the temp folder. (so it runs from temp) And then run the rest of the code, notepad.exe and traymenu etc... Reason: If someone downloads my test.exe to desktop and execute it, they need to be able to delete the test.exe from desktop. So it needs to be run from temp... This is my script: ; Script name is test.exe #requireadmin DirCreate (@TempDir & "\test") FileInstall("notepad.exe", @TempDir & "\test\notepad.exe", 1) FileCopy(@ScriptFullPath, @TempDir & "\test\", 1) Opt("TrayOnEventMode", 1) Opt("TrayMenuMode", 1) ; Tray menu items $MenuItem1 = TrayCreateItem("Stop") TrayItemSetOnEvent(-1, "MenuItem1Click") TrayTip("", "Test", 10, 1) ; Run notepad.exe Run(@TempDir & "\test\notepad.exe") While 1 Sleep(100) WEnd Func MenuItem1Click() ProcessClose("notepad.exe") Exit EndFunc Tia Edited November 5, 2008 by nitr0
senthor Posted November 5, 2008 Posted November 5, 2008 I Did it like this: If $CMDLine[0] > 0 and FileExists($CMDLine[1]) and @compiled = 1 Then Sleep(100) If StringRight($CMDLine[1], 4) = ".exe" then FileDelete($CMDLine[1]) EndIf If @ScriptDir <> @tempdir & "\test" Then DirCreate(@tempdir & "\test") FileCopy(@autoitexe, @tempdir & "\test\" & @scriptname, 1) Run(@tempdir & "\test\" & @scriptname & ' "' & @scriptfullpath & '"') Exit EndIf senthor FileListToArray UDFMy tools
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