1

I want to run two cmd commands in vb.net

Dim command As String ="Net USE \\serverip\IPC$ password /USER:username"

 Dim command2 As String ="shutdown /r /t 3 /m \\serverip"

Process.Start("cmd.exe", "/k" + command)

Process.Start("cmd.exe", "/C" + command2)

Command window is opened how can we close this.

I try process.kill() it is not working.

Vivek S.
  • 19,945
  • 7
  • 68
  • 85
ADNAN ZAMAN
  • 68
  • 1
  • 10
  • Did you try this - http://stackoverflow.com/questions/12477776/run-cmd-silently – Vivek S. Dec 28 '16 at 08:13
  • Thanks @wingedpanther .It's working fine for me – ADNAN ZAMAN Dec 28 '16 at 08:38
  • Even though you make the CMD window invisible, chances are that it is still opened. Add `exit` to the end of **both** commads: **1)** `Process.Start("cmd.exe", "/k " & command & " & exit")` **2)** `Process.Start("cmd.exe", "/C " & command2 & " & exit")`. – Visual Vincent Dec 28 '16 at 13:05
  • Please also read [**this**](http://stackoverflow.com/questions/734600/the-difference-between-and-for-joining-strings-in-vb-net) – Visual Vincent Dec 28 '16 at 13:08
  • i cannot put exit at the end of first command because i need need opened after second command first command shuld be closed – ADNAN ZAMAN Dec 28 '16 at 13:26

0 Answers0