Windows Scripting
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsSystem AdministrationWindows Scripting

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old October 12th, 2006, 02:47 PM
Rvl1980 Rvl1980 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Sep 2006
Posts: 9 Rvl1980 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 15 m 54 sec
Reputation Power: 0
VBS WSH -> getting a string from a dos excutable

Is there a way to pass what a dos executable into a varible in a vbs?



Here is the code:

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


' open normal and don't wait
WSHShell.Run "CheckCorruptImage.exe ./ *.jpg no >>log.txt", 1, false

Set WSHShell = Nothing
WScript.Quit(0)

How would I get the string to this?

tempVar = WSHShell.Run "CheckCorruptImage.exe ./ *.jpg no >>log.txt", 1, false

the executable return a problem with the path of the image if its is corrupt.

Reply With Quote
  #2  
Old October 12th, 2006, 05:45 PM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 23 h 19 m 36 sec
Reputation Power: 181
Clumsy, but you could always use the filesystem object to open and read the log file.

I've seen VB6 code that uses some windows api to capture the output of a dos program, but I don't know how or if you can do that with wscript.
__________________
======
Doug G
======
I didn't attend the funeral, but I sent a nice letter saying I approved of it. --Mark Twain

Reply With Quote
  #3  
Old October 16th, 2006, 01:27 PM
Nilpo's Avatar
Nilpo Nilpo is offline
ASP Free Beginner (1000 - 1499 posts)
 
Join Date: Jun 2006
Location: Salem, OH
Posts: 1,048 Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)  Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 5 Days 12 h 32 m 33 sec
Reputation Power: 555
Send a message via ICQ to Nilpo Send a message via AIM to Nilpo Send a message via MSN to Nilpo Send a message via Yahoo to Nilpo Send a message via Google Talk to Nilpo Send a message via Skype to Nilpo
MySpace
But of course you can! WSH would be much good without this capability now would it?

Do some Googling for the WSH's WshScriptExec object. If you need a little more help, just post back and I'll be glad to go into more detail.

Hint:

WSH has two native methods for executing command lines (or batch file ).

object.Run()
object.Exec()

Run will only return an error code. Exec, however, allows you to work with the output generated by a command.

These are the two pieces of info you need. You'll use the Exec() method to run your batch file and the WshScriptExec object to retrieve its output.

Alternatively, you could run all of your batch commands in native WSH. You can use the StdOut object to work with output and avoiding having to run an external program.

Reply With Quote
  #4  
Old October 16th, 2006, 01:56 PM
Nilpo's Avatar
Nilpo Nilpo is offline
ASP Free Beginner (1000 - 1499 posts)
 
Join Date: Jun 2006
Location: Salem, OH
Posts: 1,048 Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)Nilpo User rank is Colonel (50000 - 60000 Reputation Level)  Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 5 Days 12 h 32 m 33 sec
Reputation Power: 555
Send a message via ICQ to Nilpo Send a message via AIM to Nilpo Send a message via MSN to Nilpo Send a message via Yahoo to Nilpo Send a message via Google Talk to Nilpo Send a message via Skype to Nilpo
MySpace
I decided to just go ahead and construct the code. One thing you may need to test. I seem to remember the Exec method requiring full paths, so you may need to add the location to your executable. Anyway, here's your basic code construct.
Code:
Set objShell = CreateObject("WScript.Shell")
Set objWshScriptExec = objShell.Exec("CheckCorruptImage.exe ./ *.jpg no >> log.txt")
Set objStdOut = objWshScriptExec.StdOut
strOutput = objStdOut.ReadAll
WScript.Echo strOutput

Reply With Quote
  #5  
Old January 9th, 2007, 05:11 PM
Rvl1980 Rvl1980 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Sep 2006
Posts: 9 Rvl1980 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 15 m 54 sec
Reputation Power: 0
Quote:
Originally Posted by Nilpo
I decided to just go ahead and construct the code. One thing you may need to test. I seem to remember the Exec method requiring full paths, so you may need to add the location to your executable. Anyway, here's your basic code construct.
Code:
Set objShell = CreateObject("WScript.Shell")
Set objWshScriptExec = objShell.Exec("CheckCorruptImage.exe ./ *.jpg no >> log.txt")
Set objStdOut = objWshScriptExec.StdOut
strOutput = objStdOut.ReadAll
WScript.Echo strOutput




Thanks I will give that a try

Reply With Quote
Reply

Viewing: ASP Free ForumsSystem AdministrationWindows Scripting > VBS WSH -> getting a string from a dos excutable


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT