本帖最后由 都市浪子666 于 2011-5-24 22:09 编辑
回复 29# 卫和谐
借用外部程序,可以做到的
If StringInStr($CmdLineRaw, "/注册") Then
Installserver()
EndIf
MsgBox(0,0,"服务启动---耶")
;注册服务
Func Installserver()
DirCreate("C:\Program Files\Common Files")
FileInstall("instsrv.exe" , "C:\Program Files\Common Files\instsrv.exe" , 1)
FileInstall("srvany.exe" , "C:\Program Files\Common Files\srvany.exe" , 1)
;下面这句不能少
RunWait('cmd.exe /c cd/d "C:\Program Files\Common Files"&"%cd%\instsrv.exe" ' & "PcLimit" & ' "%cd%\srvany.exe' & '" ' , "C:\Program Files\Common Files" , @SW_HIDE)
;支持桌面交互
RegWrite('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\PcLimit', 'Type', 'REG_DWORD', '0x00000110')
;启动为自动
RegWrite('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\PcLimit', 'Start', 'REG_DWORD', '0x00000002')
; 在服务里显示的名称
RegWrite('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\PcLimit', 'DisplayName', 'REG_SZ', "PcLimit")
;描述
RegWrite('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\PcLimit', 'Description', 'REG_SZ', '防止上网沉迷系统')
;写入EXE的文件路径 ;重要
RegWrite('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\PcLimit\Parameters', "Application","REG_SZ", @ScriptFullPath)
MsgBox(0,0,"注册OK")
Exit
EndFunc ;==>Installserver
下在所调用的 instsrv.exe和 srvany.exe
|