WshShell.Exec Passing Invalid Argument to CL App 
Author Message
 WshShell.Exec Passing Invalid Argument to CL App

I'm stumped with this problem. I've got a command line utility that reports
info about Macintosh files that are stored on a Windows server (that's not
really relevant to this problem though, I don't think). The syntax is as
follows:

C:\macbinconv.exe -mb "C:\Dir 1\Dir 2\file.bin" -info

If I run this directly from the command line, it *always* works correctly.
The file refernce can be a local file or it can be a file on a remote server
referenced by its UNC path. So for example, the following also works:

C:\macbinconv.exe -mb "\\SERVER05\Dir 1\file.bin" -info

I need to be able to call this util from an ASP app, so I thought I'd just
use the WshShell object. However it is not working when the file reference
is a UNC path.

This works:

--snip--
Set WshShell = Server.CreateObject("WScript.Shell")
cmd = "C:\macbinconv.exe -mb ""C:\Dir 1\Dir 2\file.bin"" -info"
Set oExec = WshShell.Exec(cmd)
--snip--

But this noes NOT work:

--snip--
Set WshShell = Server.CreateObject("WScript.Shell")
cmd = "C:\macbinconv.exe -mb "\\SERVER05\Dir 1\file.bin" -info"
Set oExec = WshShell.Exec(cmd)
--snip--

It errors out as if the file refernce is not correct. I can get the same
behavior by manually running the util from the comand line but leaving off
the quotes around the file reference. That led me to believe that maybe
something was wrong with the way the quotes were included in the file
reference. I tried removing the quotes, escaping the quotes, double quotes,
single quotes, basically every quote trick, but that made no difference.

This is driving me crazy. This util is something I got from Sourceforge.net,
unfortunately I'm not proficent in C++ to look at the source and see if the
problem lies there.

What I'm wondering though, does this seem like it could be a bug in the
utility itself, or is there something screwy with the way that the arguments
are being passed to the util via WshShell.Exec? I can't figure why it would
work perfectly fine if invoke from the command line but fail if invoked via
WshShell.Exec. Doesn't WshShell.Exec do exactly the same thing as when the
command is manually entered? Perhaps I'm missing something simple here. Any
insight would be greatly appreciated.

Thnx
Chris M



Tue, 13 Dec 2005 09:28:01 GMT  
 WshShell.Exec Passing Invalid Argument to CL App

Quote:

> But this noes NOT work:

> --snip--
> Set WshShell = Server.CreateObject("WScript.Shell")
> cmd = "C:\macbinconv.exe -mb "\\SERVER05\Dir 1\file.bin" -info"
> Set oExec = WshShell.Exec(cmd)
> --snip--

In case anyone notices that I only have single quotes around the file
reference in the "does not work" example, I already realized that. It was a
typo on my part. Those should be double-double quotes. It should read:

cmd = "C:\macbinconv.exe -mb ""\\SERVER05\Dir 1\file.bin"" -info"

Chris M



Tue, 13 Dec 2005 09:49:50 GMT  
 WshShell.Exec Passing Invalid Argument to CL App

Quote:
> I need to be able to call this util from an ASP app, so I thought I'd
> just use the WshShell object. However it is not working when the file
> reference is a UNC path.

Q197964 - PRB: Cannot Access Remote Files with the FileSystemObject
http://support.microsoft.com/default.aspx?kbid=197964

Q207671 - HOW TO: Access Network Files from IIS Applications
http://support.microsoft.com/default.aspx?kbid=207671

--
Michael Harris
Microsoft.MVP.Scripting
Seattle WA US

Technet Script Center
http://www.microsoft.com/technet/scriptcenter/default.asp

Microsoft? Windows?2000 Scripting Guide
http://www.microsoft.com/technet/scriptcenter/scrguide/sagsas_overvie...



Tue, 13 Dec 2005 10:30:43 GMT  
 WshShell.Exec Passing Invalid Argument to CL App

Quote:
>> I need to be able to call this util from an ASP app, so I thought I'd
>> just use the WshShell object. However it is not working when the file
>> reference is a UNC path.

> Q197964 - PRB: Cannot Access Remote Files with the FileSystemObject
> http://support.microsoft.com/default.aspx?kbid=197964

> Q207671 - HOW TO: Access Network Files from IIS Applications
> http://support.microsoft.com/default.aspx?kbid=207671

Rrrrrrrrrrr! Permission problems!

Thanks for pointing me in the right direction. It was totally a permission
problem. I had the IUSR account set up properly, but failed to config the
IWAM account. Been burned by permissions enough, you'd think I'd learn.



Wed, 14 Dec 2005 00:31:52 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. WshShell.Run vs WshShell.Exec

2. runas with WshShell.Exec versus WshShell.Run

3. Arguments and data - can you pass them between VBScript and other MS Apps

4. Arguments : Passing Arguments containing <">

5. How to wait for termination of program started with WshShell.Exec

6. using WshShell.Exec

7. - WSHSHELL.EXEC error in ASP Web Page

8. WshShell.Exec what is wrong?

9. WSH 5.6 WshShell.Exec - Minimized Window?

10. Basic WshShell.Exec problem

11. WshShell.Exec: reaping return codes and waiting for termination

12. q: asynch piping of WshShell.Exec.StdOut

 

 
Powered by phpBB® Forum Software