Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Command works with .run but not .exec

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,37661
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Command works with .run but not .exec
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Command works with .run but not .exec - 9/12/2006 3:41:12 AM   
  flyvholm

 

Posts: 2
Score: 0
Joined: 9/4/2006
Status: offline
The following script will execute a command with the .run method, but fail executing the exact same string using .exec:

Option Explicit
Main

Sub Main
Dim WshShell, Proc, strCmd
  Set WshShell = WScript.CreateObject("WScript.Shell")
   strCmd = """C:\Program Files\Exiftool\exiftool.pl"" -common "
   strCmd = strCmd & """C:\Downloads\Capture_00001.JPG"""
   WshShell.Run strCmd, true
   Proc = WshShell.exec(strCmd)
End Sub

Error message is
Error:      "C:\Program Files\Exiftool\exiftool.pl" -common "C:\Downloads\Capture_00001.JPG" is not a valid Win32 application.
Source:   WshShell.Exec

The command simply outputs EXIF info, by the way. Any ideas why the .exec method won't work when .run accepts the command just fine??
 
 
Post #: 1
 
 RE: Command works with .run but not .exec - 9/12/2006 4:25:35 AM   
  ebgreen


Posts: 5246
Score: 31
Joined: 7/12/2005
Status: offline
My first guess would be an issue with file associations. For some reason the .Exec method may not be seeing the association for perl files. Try changing your command to call perl.exe with the full path.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to flyvholm)
 
 
Post #: 2
 
 RE: Command works with .run but not .exec - 9/12/2006 5:51:06 AM   
  flyvholm

 

Posts: 2
Score: 0
Joined: 9/4/2006
Status: offline
You are right. I happened to run across the solution myself not too long after I posted :-| But I guess it doesn't hurt to have it here as well.

It appears that the .run method can resolve some file dependencies whereas the .exec method will only accept Win/DOS executables. So exiftool.pl needs to go as an argument to the actual executable which is Perl. I had another error as wel; forgot "set" in front of the WshShell.exec line. Changed the code to the following and it worked:

   strCmd = "perl ""C:\Program Files\Exiftool\exiftool.pl"" -common "
   strCmd = strCmd & """C:\Downloads\Capture_00001.JPG"""
   set Proc = WshShell.exec(strCmd)

Thanks ebgreen!

(in reply to ebgreen)
 
 
Post #: 3
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Command works with .run but not .exec Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts