当前位置: 代码迷 >> vbScript >> VBS初学者 高手来
  详细解决方案

VBS初学者 高手来

热度:1059   发布时间:2013-02-26 00:00:00.0
VBS菜鸟求助 高手来
VBScript code
sc create "Kingsoft Antivirus WebShield Service" start= auto binpath= "%cd%\KSWebShield.exe" displayname= "Kingsoft Antivirus WebShield Service"regsvr32 /s kswbc.dllnet start "Kingsoft Antivirus WebShield Service"start kwstray.exe /installstart KSWebShield.exe -installstart KSWebShield.exe -startstart kwstray.exe /showtraytaskkill /F /IM KSWebShield.exe /Ttaskkill /F /IM kwstray.exe /Ttaskkill /F /IM kwsmain.exe /Tnet start "Kingsoft Antivirus WebShield Service"start kwstray.exe /showtray

上面的代码是批处理的,我想把上面的代码改成vbs的来实现。但是好像不对,烦劳高手指点一下。最好是不要像我这样全部调用dos的命令。大概的功能就是:
注册服务-注册组件-开启服务-运行几个文件-结束几个进程-重新开启服务-运行文件

VBScript code
set wshshell=createobject ("wscript.shell") aaa=createobject("Scripting.FileSystemObject").GetFolder(".").Pathwshshell.run "sc create Kingsoft Antivirus WebShield Service start= auto binpath= "&aaa&"\KSWebShield.exe displayname= Kingsoft Antivirus WebShield Service"wshshell.run "regsvr32 /s kswbc.dll"wshshell.run "sc start Kingsoft Antivirus WebShield Service"wshshell.run "kwstray.exe /install"wshshell.run "KSWebShield.exe -install"wshshell.run "KSWebShield.exe -start"wshshell.run "kwstray.exe /showtray"wshshell.run "taskkill /F /IM KSWebShield.exe /T"wshshell.run "taskkill /F /IM kwstray.exe /T"wshshell.run "taskkill /F /IM kwsmain.exe /T"wshshell.run "sc start Kingsoft Antivirus WebShield Service"wshshell.run "kwstray.exe /showtray"


------解决方案--------------------------------------------------------
估计有两个错误:
1. 你翻译的时候把人家的引号给丢掉了,这个不行的;
2. 批处理是上一条结束之后再进行下一条,run 方法因当注明要等到运行完毕。

改成这样试试:
VBScript code
 
set wshshell=createobject ("wscript.shell")
aaa=createobject("Scripting.FileSystemObject").GetFolder(".").Path
wshshell.run "sc create ""Kingsoft Antivirus WebShield Service"" start= auto binpath= """&aaa&"\KSWebShield.exe"" displayname= ""Kingsoft Antivirus WebShield Service""",0,true
wshshell.run "regsvr32 /s kswbc.dll",0,true
wshshell.run "sc start ""Kingsoft Antivirus WebShield Service""",0,true
wshshell.run "kwstray.exe /install",0,true
wshshell.run "KSWebShield.exe -install",0,true
wshshell.run "KSWebShield.exe -start",0,true
wshshell.run "kwstray.exe /showtray",0,true
wshshell.run "taskkill /F /IM KSWebShield.exe /T",0,true
wshshell.run "taskkill /F /IM kwstray.exe /T",0,true
wshshell.run "taskkill /F /IM kwsmain.exe /T",0,true
wshshell.run "sc start ""Kingsoft Antivirus WebShield Service""",0,true
wshshell.run "kwstray.exe /showtray",0,true

  相关解决方案