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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Launching cmd.exe from VBA

Status
Not open for further replies.

ken2834

Technical User
Jun 26, 2006
27
US
I have a VBA module that launches a DOS command console (cmd.exe) in order to login to a Unix session and then run some FTP commands to pull down a file from the Unix server. However, I would like to be able to parse the output in the console to determine if the login occurred successfully. Is this possible? I don't see a way to do this.
 
ken2834,
From the command prompt you can ouput the screen to a file using [tt]> filename[/tt], for example you can create a file with directory listing using the following:
Code:
C:\>[b]dir > c:\testfile.txt[/b]
I get the following output:

[tt]
Volume in drive C is Preload
Volume Serial Number is F8B1-679E

Directory of C:

02/26/2007 10:08 PM <DIR> .
02/26/2007 10:08 PM <DIR> ..
02/20/2007 10:02 PM 392 iexplore.exe_Trace.txt
1 File(s) 392 bytes
2 Dir(s) 41,524,248,576 bytes free[/tt]

It should work with anything you do from the command prompt that returns 'stuff'. Once file is created it's pretty easy to open/read/process in VBA.

Hope this helps,
CMP

[small]For the best results do what I'm thinking, not what I'm saying.[/small]
(GMT-07:00) Mountain Time (US & Canada)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top