Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
automat delete after Running successfully?
#1
Which function to use? so that exe file automat delete after Running successfully ?

I know: End of the batch file, I use the code ( del %0 ) When the batch run is complete, I can automatically delete the batch file.

but: In the QM code, before the creation of exe, Add what code can be achieved? Thanks in advance,I hope someone can help me find a way ! Tongue
#2
Exe cannot delete itself directly. The OS does not allow it. Try to launch a .bat or something that deletes it after eg 1 second.
#3
I used the following code to remove the exe file but did not succeed :oops:


Macro Macro4
Code:
Copy      Help
str s=
;Del /f /q %desktop%\Macro4.exe

__TempFile f.Init(".bat" "" "" s)
RunConsole2 f
#4
RunConsole2 waits. Use run, it does not wait. Don't use __TempFile, instead let the .bat delete self.
#5
Macro Macro2829
Code:
Copy      Help
mes "macro"

;delete this exe
#if EXE=1
str s=
F
;timeout 2
;del "{ExeFullPath}"
;del %0
str tempFile="$temp$\delete my exe.bat"
s.setfile(tempFile)
run tempFile "" "" "" 16
#endif
#6
The following code is found in the ahk forum: ahk generated exe, I can automatically delete the exe file, how to use it in Qm? Idea


delself()
{
if (A_IsCompiled)

{

bat=

(LTrim

Confusedtart

ping 127.0.0.1 -n 2>nul

del `%1

if exist `%1 goto start



del `%0

)

batfilename=delete.bat



IfExist %batfilename%

FileDelete %batfilename%



FileAppend, %bat%, %batfilename%



Run, %batfilename% "%A_ScriptFullPath%", , Hide

ExitApp

}
}
#7
Gintaras Wrote:Macro Macro2829
Code:
Copy      Help
mes "macro"

;delete this exe
#if EXE=1
str s=
F
;timeout 2
;del "{ExeFullPath}"
;del %0
str tempFile="$temp$\delete my exe.bat"
s.setfile(tempFile)
run tempFile "" "" "" 16
#endif

Test success, thank you very much Big Grin
#8
Note that the timeout command is unavailable on Windows XP. It seems the most reliable workaround is ping, like in the ahk script.

http://stackoverflow.com/questions/1672 ... mpt-or-dos
#9
Thank you for the reminder that I have replaced the following code: Smile

Macro Macro7
Code:
Copy      Help
mes "macro"

;delete this exe
#if EXE=1
str s=
F
;ping 127.0.0.1 -n 2>nul
;del "{ExeFullPath}"
;del %0
str tempFile="$temp$\delete my exe.bat"
s.setfile(tempFile)
run tempFile "" "" "" 16
#endif


Forum Jump:


Users browsing this thread: 1 Guest(s)