Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Beginning VB 6
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old December 10th, 2003, 04:17 AM
Registered User
 
Join Date: Nov 2003
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Pass arguments to dos program

Hi,

I am writing a small disk management program. I would like to be able to call some of the dos functions via my program. But the dos functions sometimes ask for arguments, such as 'are you sure?', and then one needs to type in 'y'.

I have seen that one can create a response.tmp file, that contains the arguments to pass to the dos program. i,e

Private Sub Form_Load()
 x = Shell("format a:\ < c:\response.tmp", SW_HIDE)
End Sub

Now this dos command works when I type it in dos, it formats the disk automatically.

But when I try to execute the dos command in my VB program, I get the error, file not found. I have heard something about a WinExec function, but am not sure how to use it... take the following code

Declare Function WinExec Lib "Kernel" (ByVal lpCmdFile As String, ByVal
   fuCmdShow As Integer) As Integer

How do I place this in my code, wherever I place this code, VB gives me an error.

Thanks
Greg

Reply With Quote
  #2 (permalink)  
Old December 10th, 2003, 05:38 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , United Kingdom.
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

Take a look at the Windows Scripting Host objects, in particular the WScript.Shell object and its Exec method. When you use the Exec method to run a program, it returns a WshScriptExec object which provides access to stdin and stdout, which you can use to capture the program output and send a reply.

You need to set a ref to 'Windows Script Host Object Model' in your VB project.

hth
Phil
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Send Keystrokes to DOS Program from Access VBA Cosmos75 Access VBA 6 May 15th, 2007 06:24 PM
take arguments when running program in console iulian C++ Programming 8 January 16th, 2007 09:17 AM
Setup Project: Program not added in Start>Program arif_1947 VS.NET 2002/2003 2 March 31st, 2005 06:40 AM
Program arguments bramtram VB How-To 1 August 14th, 2003 03:18 AM



All times are GMT -4. The time now is 03:46 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.