So my script below has a simple task, enable or disable the windows installer service in safe mode. I'm having a hard time seeing the issue with it though. I've determined I'm messing up my if / goto section at the top but can't for the life of me figure out what I'm doing wrong. The small bits of vbs work fine and the comparison appears to be formatted correctly but it keeps failing with a syntax error on the first if statement. Any pointers would be greatly appreciated.
Call :ChoiceBox "Do you want to activate the installer service?"
If %YesNo% == "6"(
goto :AddRegkey
)
If %YesNo% == "7"(
goto :RemoveRegkey
)
pause
:ChoiceBox
REM returns 6 = Yes, 7 = No Type=4 = Yes/No
set YesNo=
set MsgType=4
set heading=%~2
set message=%~1
echo wscript.echo msgbox(WScript.Arguments(0),%MsgType%,WScript.Arguments(1)) >"%temp%\input.vbs"
for /f "tokens=* delims=" %%a in ('cscript //nologo "%temp%\input.vbs" "%message%" "%heading%"') do set YesNo=%%a
exit /b
:RemoveRegkey
net stop msiserver
REG DELETE "HKLM\SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\MSIServer" /VE /T REG_SZ /F /D "Service"
REG DELETE "HKLM\SYSTEM\CurrentControlSet\Control\SafeBoot\Network\MSIServer" /VE /T REG_SZ /F /D "Service"
echo msgbox "Registry entries deleted." > %temp%\tempmsg.vbs
call %temp%\tempmsg.vbs
del %temp%\tempmsg.vbs /f /q
exit /b
:AddRegkey
REG ADD "HKLM\SYSTEM\CurrentControlSet\Control\SafeBoot\Minimal\MSIServer" /VE /T REG_SZ /F /D "Service"
REG ADD "HKLM\SYSTEM\CurrentControlSet\Control\SafeBoot\Network\MSIServer" /VE /T REG_SZ /F /D "Service"
echo msgbox "Registry entries added." > %temp%\tempmsg.vbs
call %temp%\tempmsg.vbs
del %temp%\tempmsg.vbs /f /q
net start msiserver
exit /b
Aucun commentaire:
Enregistrer un commentaire