For Programmers: Free Programming Magazines  


Home > Archive > Visual Basic > October 2004 > Run MS-DOS command while working in Visual Basic









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Run MS-DOS command while working in Visual Basic
Pushpak

2004-10-08, 8:55 am

Hello! I have a Question in VB. How Do I Run a MS-DOS Cmd in Visual Basic
Environment. e.g. TYPE info.txt > prn. I dont wan to use common dialoguebox
controls.
Thanks.
Pushpak
Bonj

2004-10-08, 3:55 pm

Use the "Shell" command
if you want to run a command like "dir" that relies on the command
interpreter use
Shell environ("comspec") & " /c """ & strCommand & """"

otherwise, just use
Shell strCommand




HTH
Cheers

Rick Rothstein

2004-10-08, 3:55 pm

> Use the "Shell" command
> if you want to run a command like "dir" that relies on the command
> interpreter use
> Shell environ("comspec") & " /c """ & strCommand & """"
>
> otherwise, just use
> Shell strCommand


My suggestion is to **always** specify the command interpreter when
using the Shell command... while it is needed for internal commands (as
you have pointed out), it does not hurt to specify it for commands that
are not internal. This way, the programmer will not have to maintain two
different versions of the Shell call.

Rick - MVP

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com