wsfda
发表于 2011-5-24 21:28:20
回复 23# m765555
能否告知你以前如何做服务的,你的exe文件做了什么吗
都市浪子666
发表于 2011-5-24 21:31:18
本帖最后由 都市浪子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
卫和谐
发表于 2011-5-25 08:12:50
回复 32# 都市浪子666
谢谢,不想借用外部程序,想用AU3解决!
m765555
发表于 2011-5-25 08:20:52
我也是借用外部做服务,AU3做服务没有成功过,有待研究
卫和谐
发表于 2011-5-25 08:27:32
回复 34# m765555
调用的这2个程序,不知道起什么 作用?
m765555
发表于 2011-5-25 08:31:35
instsrv.exe和 srvany.exe
给服务注册执行等呀,缺一不可。
wsfda
发表于 2011-5-25 08:44:48
希望纯au3可以
卫和谐
发表于 2011-5-25 12:25:33
刚才查了一下资料,instsrv.exe是添加、删除服务的,srvany.exe是注册服务的!
leon460
发表于 2011-7-12 16:25:02
我也曾经 instsrv.exe 成功添加服务,但是用au3不知道怎么弄
leibin0121
发表于 2011-9-9 17:30:24
高手太多了,学习学习。
dosy001
发表于 2013-2-25 09:39:32
的工具将自己的程序注册为服务,服务可以正常启
zym3138
发表于 2013-3-4 22:18:29
回复 15# easefull
我觉得应该是这样的。说得对