如何在nsis脚本中编写.bat文件

时间:2018-04-08 10:07:34

标签: nsis

$INSTDIR\DOWNPRINT\runRestart.bat" "TEXT" "@ECHO OFFdel $INSTDIR\DOWNPRINT\process.txtwmic process  get processid,name,commandline /format:csv | findstr "runPosiboltprint.bat" | findstr /V "findstr"  > $INSTDIR\DOWNPRINT\process.txt(for /f "tokens=3,* delims=," %%a in($INSTDIR\DOWNPRINT\process.txt) do @echo %%b) >$INSTDIR\DOWNPRINT\pid.txtcd $INSTDIR\DOWNPRINT\SET /P A= < $INSTDIR\DOWNPRINT\pid.txttaskkill.exe /F  /PID  %A%$INSTDIR\Java\bin\java.exe -jar $INSTDIR\DOWNPRINT\printer.jar

这是我的批处理脚本

我已经尝试过FileWrite和WriteIniStr。但两者都抛出了一个错误 WriteIniStr需要4个参数,得到28.并且FileWrite需要4个参数,得到28个。

任何人请帮助我!

1 个答案:

答案 0 :(得分:1)

使用FileWrite时需要引用字符串:

Section
InitPluginsDir
FileOpen $0 "$pluginsdir\myscript.bat" w
FileWrite $0 '@echo off$\r$\n'
FileWrite $0 'echo Hello world$\r$\n'
FileWrite $0 'echo foo "bar" | find /I "FOO" > $pluginsdir\temp.txt $\r$\n'
FileClose $0

ReadEnvStr $0 COMSPEC
nsExec::Exec  '"$0" /c "$pluginsdir\myscript.bat"' ; Run the batch with a hidden window. Use ExecWait if you want a visible window
Pop $0
DetailPrint "Returned $0"
SectionEnd