[RESOLVED] Command shel Help for VB studio[2005] I HOPE ITS POSSIBLE!!!!!!!!!!!!!
Hi, I'm fairly new to vb 2005 but am very good with vb6... so my main question is how do I send dos commands to the computer without having the user open any command prompts. SO example I would like to execute this command from my program...
EX: C:\>IpConfig
and of course all the output would be shown... This program will be only to show your ip and other dos command tasks. It has to be dos and no other method PLEASE. I need it to be able to communicate with dos like a command prompt. Thanks for viewing my post and hope any of you experts could help me out with this tricky yet fun task.
Re: Command shel Help for VB studio[2005] I HOPE ITS POSSIBLE!!!!!!!!!!!!!
well....you can still use Shell(stringCommand) like before...but as far as actually showing the result, i'm not sure.
Re: Command shel Help for VB studio[2005] I HOPE ITS POSSIBLE!!!!!!!!!!!!!
Depending on the amount of control, you could use ProcessStartInfo to execute a command prompt window passing the dos arguments.
The /C means to close the command window when complete. /K would mean to keep it open.
vb Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim oPSI As New System.Diagnostics.ProcessStartInfo
With oPSI
.FileName = "C:\Windows\System32\cmd.exe"
.CreateNoWindow = True
.WindowStyle = ProcessWindowStyle.Hidden
.WorkingDirectory = "C:\Users\VB-Guru\"
.UseShellExecute = True
.Arguments = "/C Ping google.com > PingResults.txt"
End With
System.Diagnostics.Process.Start(oPSI)
End Sub
Re: Command shel Help for VB studio[2005] I HOPE ITS POSSIBLE!!!!!!!!!!!!!
Thank you verry much for the quick responce time.... RobDog888 your code did exactly what i was looking for and thank you very much.
Re: Command shel Help for VB studio[2005] I HOPE ITS POSSIBLE!!!!!!!!!!!!!
No prob. Glad to help. :)
I added an enhancement for opening the textfile (optional) when its done processing.
vb Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim oPSI As New System.Diagnostics.ProcessStartInfo
Dim oProcess As System.Diagnostics.Process
With oPSI
.FileName = "C:\Windows\System32\cmd.exe"
.CreateNoWindow = True
.WindowStyle = ProcessWindowStyle.Hidden
.WorkingDirectory = "C:\Users\VB-Guru\"
.UseShellExecute = True
.Arguments = "/C Ping google.com > PingResults.txt"
End With
oProcess = System.Diagnostics.Process.Start(oPSI)
oProcess.WaitForExit()
System.Diagnostics.Process.Start(oPSI.WorkingDirectory & "PingResults.txt")
End Sub
Re: Command shel Help for VB studio[2005] I HOPE ITS POSSIBLE!!!!!!!!!!!!!