Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/svg/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
VBScript WScript.Shell Run()-系统找不到指定的文件_Vbscript_Wsh - Fatal编程技术网

VBScript WScript.Shell Run()-系统找不到指定的文件

VBScript WScript.Shell Run()-系统找不到指定的文件,vbscript,wsh,Vbscript,Wsh,我正在尝试编写一个使用WScript.ShellRun()方法的VBScript(.vbs)脚本,但似乎Run()找不到我传递的文件 我已经将我的脚本归结为以下代码,这些代码将重现结果。可以将其复制到文本编辑器中,另存为test.vbs并运行。type命令只输出传入文件中的文本 如果要直接从CMD提示符运行run()中的代码,它可以正常工作。但是,当从.vbs脚本内部运行并使用run()时,会出现以下错误: Test.vbs(4, 1) (null): The system cannot fin

我正在尝试编写一个使用WScript.ShellRun()方法的VBScript(.vbs)脚本,但似乎Run()找不到我传递的文件

我已经将我的脚本归结为以下代码,这些代码将重现结果。可以将其复制到文本编辑器中,另存为test.vbs并运行。type命令只输出传入文件中的文本

如果要直接从CMD提示符运行run()中的代码,它可以正常工作。但是,当从.vbs脚本内部运行并使用run()时,会出现以下错误:

Test.vbs(4, 1) (null): The system cannot find the file specified.
我可以使用run()很好地运行其他命令,但当我尝试传递路径时,它失败了。顺便说一句,Exec()失败了,并且出现了相同的错误。有什么想法吗?

试试这个

Set oShell = CreateObject("WScript.Shell")

strCmd = "cmd /K type C:\inetpub\wwwroot\iisstart.htm"

oShell.Run(strCmd)

Set oShell = Nothing

必须使用
cmd.exe.k
,因为
TYPE
不是实际的可执行程序,而是cmd命令处理器中的内部命令。
Set oShell = CreateObject("WScript.Shell")

strCmd = "cmd /K type C:\inetpub\wwwroot\iisstart.htm"

oShell.Run(strCmd)

Set oShell = Nothing