Jump to content
Sign in to follow this  

copy script to temp then run

Recommended Posts


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

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

Func MenuItem1Click()


Edited by nitr0

Share this post

Link to post
Share on other sites

I Did it like this:

If $CMDLine[0] > 0 and FileExists($CMDLine[1]) and @compiled = 1 Then
    If StringRight($CMDLine[1], 4) = ".exe" then FileDelete($CMDLine[1])

If @ScriptDir <> @tempdir & "\test" Then
    DirCreate(@tempdir & "\test")
    FileCopy(@autoitexe, @tempdir & "\test\" & @scriptname, 1)
    Run(@tempdir & "\test\" & @scriptname & ' "'  & @scriptfullpath & '"')


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  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.