以下代码实现向本机添加多个IP地址,现在遇到这样一个问题:netsh命令会执行一小段时间,如果不加sleep,就会一下子弹出很多命令行窗口。如何能够得到oShell.run退出的信号,这样在oShell.run退出时,再执行下一句语句;或者还有其它什么方法?请大家帮帮忙,谢谢!~
ipAddr = "192.168.1."
netmask = "255.255.255.0"dim oShell, iset oShell = wscript.CreateObject ("wscript.shell")for i = 1 to 254 oShell.run ("cmd /c netsh interface ip add address 本地连接 " & ipAddr & i & " " & netmask)
wscript.sleep (4000)
nextset oShell = nothing
ipAddr = "192.168.1."
netmask = "255.255.255.0"dim oShell, iset oShell = wscript.CreateObject ("wscript.shell")for i = 1 to 254 oShell.run ("cmd /c netsh interface ip add address 本地连接 " & ipAddr & i & " " & netmask)
wscript.sleep (4000)
nextset oShell = nothing
在新过程中运行程序。object.Run(strCommand, [intWindowStyle], [bWaitOnReturn])
参数
object
WshShell 对象。
strCommand
表示要运行的命令行的字符串值。必须包括要传递到可执行文件的所有参数。
intWindowStyle
可选。表示程序窗口外观的整数值。请注意,并非所有程序都使用此信息。
bWaitOnReturn
可选。布尔值,表示在继续执行脚本中的下一条语句之前,脚本是否等待执行完程序。如果设为 true,则在执行完程序后才执行脚本,Run 方法返回由程序返回的任何错误代码。如果设为 false(默认值),则 Run 方法将自动在启动程序后立即返回 0(不是错误代码)。