# [VB6] How to run a program in the command prompt?



## bkatz540 (Oct 23, 2003)

Well heres my issue:

I need to make a server launcher for a game that I run in VB.

I need the launcher to open a program in the cmd prompt that is located on my computer.
I asked help from a friend and he told me this code:

```
Private sub command1_click() 'When you click on the command button. 
Shell ("Put here where the exe file is*") 'Opens the file 
End sub 'Ends it
```
However, when I put in the File address, compiled, and clicked run server, it gave me an error that the file is corrupted. I think I know why it says this (even though the program is not corrupted): the server runs in a command prompt. Does anyone know how to open up a program in the command prompt in VB? Thanks.

-Ben


----------



## bkatz540 (Oct 23, 2003)

anyone?


----------



## cristobal03 (Aug 5, 2005)

*Shell* does run the program in a new instance of the command prompt. I don't understand your question? If your run-time environment is telling you the file is corrupted, how do you know it isn't? The file itself may not be broken, but it may be invalid for the environment you're trying to run it in.

Anyway, *Shell* is (as far as I know) the only way to open an instance of a command prompt without going through an API or somesuch. You won't retain ownership of what occurs in the new instance of the prompt, though; your called application will have to manage that. Keep in mind that *Shell* can only run executable (specifically *exe*) files.

chris.


----------

