Ticket #739: redirect-test.nsi

File redirect-test.nsi, 744 bytes (added by Samuli Seppänen, 6 years ago)

Example NSIS script that hide sc.exe output, but warns the user on failure

Line 
1SetCompressor lzma
2
3!include "WinVer.nsh"
4!include "WordFunc.nsh"
5!include "MUI2.nsh"
6!include "LogicLib.nsh"
7
8
9Name "redirect-test 0.1"
10OutFile "redirect-test.exe"
11InstallDir "C:\Users\samuli\opt\nsistest"
12ShowInstDetails show
13
14!insertmacro MUI_PAGE_COMPONENTS
15!insertmacro MUI_PAGE_DIRECTORY
16!insertmacro MUI_PAGE_INSTFILES
17!insertmacro MUI_PAGE_FINISH
18
19Section "Main"
20        ; Get location of cmd.exe
21        ReadEnvStr $R0 COMSPEC
22        nsExec::ExecToLog '"$R0" /c "$SYSDIR\sc.exe" start openvpnserviceinteractive >nul'
23        Pop $R0
24        ${If} "$R0" == "0"
25                DetailPrint "Enabling OpenVPNService succeeded"
26        ${Else}
27                DetailPrint "WARNING: $\"sc.exe start OpenVPNServiceInteractive$\" failed with return value of $R0"
28        ${EndIf}
29SectionEnd