VBScript WScript.Shell Run () - the system cannot find the specified file

I am trying to write a VBScript (.vbs) script that uses the WScript.Shell Run () method , but it seems that Run () cannot find the file I'm going through.

I threw my script back to the following code, which will reproduce the results. This can be copied to a text editor saved as test.vbs and started. A type command simply displays the text inside the transferred file.

Dim WShell
Set WShell = WScript.CreateObject("WScript.Shell")

WShell.Run("type C:\inetpub\wwwroot\iisstart.htm")

Set WShell = Nothing

If you were to run the code in Run () directly from the CMD prompt, it works fine. But when it runs from within the .vbs script and uses Run (), it raises the following error:

Test.vbs(4, 1) (null): The system cannot find the file specified.

, Run() , , . Exec(), , . ?

+5
1

Set oShell = CreateObject("WScript.Shell")

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

oShell.Run(strCmd)

Set oShell = Nothing
+8

All Articles