Archive: Script to execute a bat


Script to execute a bat
I suck at scripting... but I need a script to execute a .bat file after extracting everything. Can anyone help me?


Just use Exec or ExecShell in a section or function.


To hide DOS window use nsExec (nsis\contrib\nsexec) or ExecDos. Anders' remark in the ExecDos thread about bat files execution is important.


Thanks!


Is there a way to make sure that the files get extracted in a precice folder? Because the paths in the .bat needs it.


Use SetOutPath first.
..or..
for single files you can use:
File "/oname=$INSTDIR\file.ext" "localfile.ext"

-Stu


One last thing... how can I make this work?

ExecShell "at 00:00 /every:Su,M,T,W,Th,F,S "cd $INSTDIR | .\update.bat""

The ExecShell command is used to execute Windows shell commands, which appear in the "right-click" menu--things such as "open", "print", etc.

So, to run a batch file, it would be something like this:


ExecShell "open" "C:\path\update.bat"


But looking at your example, it seems that that you also want to run this as batch file as a scheduled task. The only way that I know of doing this is to incorporate this into Windows as a scheduled task. This means that you're going to have to make some type of API call or call to an external EXE that will set this up.

Take a look at this forum topic to get some more information about setting up scheduled tasks in Windows:
http://forums.winamp.com/showthread....highlight=task

Thank you very much!


Well, 'at' is a command-line executable so you just need to call it with %COMSPEC%:

ReadEnvStr $R0 COMSPEC
nsExec::Exec '"$R0" /C at 00:00 /every:Su,M,T,W,Th,F,S "cd $INSTDIR | .\update.bat"'


Edit: However, I don't think at.exe is on Win9x therefore the Scheduled Tasks link will be bettr.

.bat files are not a registered Windows Shell file type as they are part of DOS/CMD. Therefore you do not need to use ExecShell on them - they act like an exe, hence why you can even use them for Shell on other file types.

-Stu

I used the Scheduled Task plugin :)