Board logo

标题: VBS调用CMD命令无法通过 [打印本页]

作者: 5872169     时间: 2008-10-31 12:21    标题: VBS调用CMD命令无法通过

请看下我的代码哪里错了??
set ws=createobject("wscript.shell")
ws.run "cmd /c for /f "skip=4 tokens=1,2 delims=:" %%a in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\WinRAR.exe" /v Path') do (
set RarPathL=%%a
set RarPathR=%%b)
set RarPath=%RarPathL:~-1%:%RarPathR%",0
作者: HAT     时间: 2008-10-31 12:25
VBS有自己的方法操作注册表,不必调用BAT
Set WshShell = WScript.CreateObject("WScript.Shell")
'写注册表
WshShell.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\cmd.exe\Debugger", "ntsd -d", "REG_SZ"
'读注册表
WScript.Echo WshShell.RegRead ("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\cmd.exe\Debugger")
'删注册表
WshShell.RegDelete "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\cmd.exe\"

作者: 5872169     时间: 2008-10-31 13:27
我想用VBS调用CMD命令应该怎么写:
for /f "skip=4 tokens=1,2 delims=:" %%a in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\WinRAR.exe" /v Path') do (
set RarPathL=%%a
set RarPathR=%%b)
set RarPath=%RarPathL:~-1%:%RarPathR%