# run dos command from windows by VB6



## DOSSARY (Feb 16, 2005)

Hi All, 

i want ask you about If I can run some of dos commands from windows by 

VB6 or no  ???

if i can ! can i get the code  


thanks 


Dossary


----------



## Arky (Aug 17, 2004)

One way is to use the Shell function e.g.:
Private Sub Command1_Click()
Dim RetVal
RetVal = Shell("c:\Temp\Test.bat", 1)
End Sub

with the DOS command embedded in the .BAT file e.g. Test.bat

DIR
PAUSE

as an example.


----------



## Mosaic1 (Aug 17, 2001)

The Command prompt which runs the bat will start in the directory from which it is called. Most dos files do not use absolute paths.

You would be better off just calling a simple command from shell and not a batch file unless that batch file used absolute paths. 
or using the shellexecute API.

I answered one like this at another forum. Here's the link to save some typing.

http://www.visualbasicforum.com/showthread.php?t=210519

What kind of command did you want to run? That can be done too by using

shell "Cmd /c" & the command

But you have a question of commas and what exactly you want to do.


----------

