Skip to content
⌘ NSIS Forum Archive

Detect System Restore Service state

7 posts

XPero#

Detect System Restore Service state

Hi all. Ive tried several ways, but I cant get it to work. I need a way to detect (On Init) if System Restore Service is ON or OFF. If it is OFF, a message box will be shown letting the user to quit installation. Is this possible? Any help will be appreciated. Thanks
Anders#
i guess the easy solution is to use RegMon and look for a registry value (by turning system restore on or off)

a better solution is probably to use WMI in a custom plugin or vbs/jscript script

http://www.microsoft.com/windowsxp/p...iptsamples.asp
dandaman32#
The best way to do this would be to call $SYSDIR\sc.exe and analyse the return.

nsExec::ExecToStack '"$SYSDIR\sc.exe" query srservice'
Calling nsExec runs the program without showing a commandline popup window.

; now get return
Pop $0
StrCpy $0 $0 7 114
;at this point $0 will be "RUNNING" if srservice is running.
You can then do what you want with the string.

Why this works:

nsExec is capable of executing commandline apps and storing the return value in the stack. Whenever "sc.exe query srservice" is called from a command prompt (try it!) the first 114 characters of its output are always the same unless your users have recklessly modified their systems.

Working script attached.

-dandaman32
XPero#
Thanks guys, will try it soon. Also I need a YES NO pop up, but I think this can be made simply editing the line "MessageBox MB_OK|MB_ICONEXCLAMATION". Thanks