Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

objShell.Run Issues

812 views
Skip to first unread message

Jeff

unread,
Apr 9, 2007, 6:23:58 PM4/9/07
to
Hi All,

I am trying to execute a batch file from a VBScript and it keeps
failing with "The system cannot find the file specified", code:
80070002, failing on the objShell.Run line. I did a lot of searching
and this should work, but doesn't.

strSysname = "Server1"
strBatch = chr(34) & "c:\temp\SvrChk.bat " & strSysname & chr(34)
objShell.Run strBatch, 0, True

Can anyone out there help?

Jeff

Adam

unread,
Apr 9, 2007, 6:49:19 PM4/9/07
to
Try this:

strSysname = "Server1"
strBatch = "c:\temp\SvrChk.bat " & strSysname
objShell.Run (strBatch), 0, True


I think if you used something like Filemon from sysinternals you'd find your
code was trying to use the entirity of strBatch as the file to execute

"Jeff" <jeff...@state.nm.us> wrote in message
news:1176157438.6...@e65g2000hsc.googlegroups.com...

Ayush

unread,
Apr 9, 2007, 7:28:40 PM4/9/07
to
[Jeff]s message :
> Hi All,

> Jeff

You are trying to run:
"c:\temp\SvrChk.bat Server1"
which is wrong.

Use either
"c:\temp\SvrChk.bat" Server1
or
c:\temp\SvrChk.bat Server1


Good Luck, Ayush.
--
Scripting- your first steps :
http://www.microsoft.com/technet/scriptcenter/topics/beginner/firststeps.mspx

Al Dunbar

unread,
Apr 11, 2007, 12:41:39 AM4/11/07
to

"Ayush" <"ayushmaan.j[aatt]gmail.com"> wrote in message
news:er34HCwe...@TK2MSFTNGP04.phx.gbl...

> [Jeff]s message :
>> Hi All,
>
>> I am trying to execute a batch file from a VBScript and it keeps
>> failing with "The system cannot find the file specified", code:
>> 80070002, failing on the objShell.Run line. I did a lot of searching
>> and this should work, but doesn't.
>
>> strSysname = "Server1"
>> strBatch = chr(34) & "c:\temp\SvrChk.bat " & strSysname & chr(34)
>> objShell.Run strBatch, 0, True
>
>> Can anyone out there help?
>
>> Jeff
>
> You are trying to run:
> "c:\temp\SvrChk.bat Server1"
> which is wrong.
>
> Use either
> "c:\temp\SvrChk.bat" Server1
> or
> c:\temp\SvrChk.bat Server1

quite correct. Converted back into vbscript we have:

strBatch = chr(34) & "c:\temp\SvrChk.bat" & chr(34) & " " & strSysname

or the form I prefer:

strBatch = """c:\temp\SvrChk.bat"" " & strSysname

/Al

Jeff

unread,
Apr 13, 2007, 2:35:00 PM4/13/07
to
On Apr 9, 4:49 pm, "Adam" <newsa...@gmail.com> wrote:
> Try this:
>
> strSysname = "Server1"
> strBatch = "c:\temp\SvrChk.bat " & strSysname
> objShell.Run (strBatch), 0, True
>
> I think if you used something like Filemon from sysinternals you'd find your
> code was trying to use the entirity of strBatch as the file to execute
>
> "Jeff" <jeff.d...@state.nm.us> wrote in message

>
> news:1176157438.6...@e65g2000hsc.googlegroups.com...
>
>
>
> > Hi All,
>
> > I am trying to execute a batch file from a VBScript and it keeps
> > failing with "The system cannot find the file specified", code:
> > 80070002, failing on the objShell.Run line. I did a lot of searching
> > and this should work, but doesn't.
>
> > strSysname = "Server1"
> > strBatch = chr(34) & "c:\temp\SvrChk.bat " & strSysname & chr(34)
> > objShell.Run strBatch, 0, True
>
> > Can anyone out there help?
>
> > Jeff- Hide quoted text -
>
> - Show quoted text -

Hi Adam,

You hit the nail on the head, your solution worked. Thanks.

0 new messages