Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unable to run commands from VBScript 1

Status
Not open for further replies.

JustScriptIt

Technical User
Oct 28, 2011
73
US
I am following the tutorial on this page


When I run the following from a command prompt

Code:
Option Explicit

Dim WshShell, objShell

' Launch Notepad with the current executed script:

Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run ("%windir%\notepad" & WScript.ScriptFullName)

' Launch Notepad with the current executed script, specify the
' window type, wait for Notepad to be shut down by the user,
' and save the error code returned from Notepad when it exits:

Set WshShell = WScript.CreateObject("WScript.Shell")
Return = WshShell.Run("notepad " & WScript.ScriptFullName, 1, true)

'Open a cmd window, change the path to C:\ , and execute the DIR command:

Set objShell = WScript.CreateObject ("WScript.shell")
objShell.run "cmd /K CD C:\ & Dir"
Set objShell = Nothing

I get the following error:

open_notepad.vbs(8, 1) (null): The system cannot find the file specified.

Why is this happening?
 
Replace this:
WshShell.Run ("%windir%\notepad" & WScript.ScriptFullName)
with this:
WshShell.Run "%windir%\notepad " & WScript.ScriptFullName

Note the missing space

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top