VB Function To Execute DOS Commands

India
March 2, 2007 11:58pm CST
Hello friends, Is there any VB functions to execute DOS commands directly? Like I want to say, let execute() be the function. The code will be like somehow this. Private Sub Command1_Click() execute("md Folder1") execute("cd Folder1") End Sub Now, Is there such any function in reality in VB???
4 responses
@ApOgEE (45)
• Malaysia
28 Mar 07
hi sribasu, There is no such code to simply execute DOS command like that. But, there is way to achieve that where you can create your own function to do that. here is the function code you have to add to run your program. Private Sub Execute(ByVal sCommand as String) Open CurDir & "\mycmd.bat" For Output As #1 Print #1, sCommand Close #1 Shell CurDir & "\mycmd.bat", vbNormalFocus End Sub
@ferdzNK (3211)
• Philippines
4 Apr 08
Elegantly executed! Using a DOS batch file to do a series of commands in one shell command!
@mnsrwt123 (2057)
• India
1 Apr 08
yeah, there's a process management feature in VB dot net and i also use this to run any command from my form and its really working nice...though...heehe
@repzkoopz (1895)
• Philippines
14 Mar 07
you can try shell commands. something like this: shell("notepad.exe")
@schenz (22)
• United States
25 Mar 07
What version of VB?