Reputation: 9
i searched google and stackoverflow alot but no solution
i was trying to pass multiple arguments in cmd they are like in this way
Dim argu1 As String = "netsh wlan set hostednetwork mode = allow ssid=" + TextBox1.Text + " key=" + TextBox2.Text
Dim argu2 As String = "netsh wlan start hostednetwork"
Dim process As System.Diagnostics.Process = Nothing
Dim processStartInfo As System.Diagnostics.ProcessStartInfo
processStartInfo = New System.Diagnostics.ProcessStartInfo
processStartInfo.FileName = "cmd.exe"
processStartInfo.Verb = "runas"
and wrote arguments in this way
processStartInfo.Arguments = argu1 & argu2
processStartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden
processStartInfo.UseShellExecute = True
Try
process = System.Diagnostics.Process.Start(processStartInfo)
Catch ex As Exception
MessageBox.Show(ex.Message, "Unknown Error !", MessageBoxButtons.OK, MessageBoxIcon.Error)
Finally
If Not (process Is Nothing) Then
process.Dispose()
End If
End Try
but nothing is happening
so plz tell me how can i pass multiple arguments
Upvotes: 0
Views: 668
Reputation: 172220
What did you expect to happen? You are executing
cmd.exe netsh wlan set hostednetwork mode = allow ssid=... key=...netsh wlan start hostednetwork
which simply starts a new instance of cmd.exe, ignoring all that netsh ...
stuff.
Please have a look at the documentation of cmd.exe. In particular, I suspect that the /c
command line switch might be what you are looking for. That said, you might want to consider calling netsh.exe directly or (even better) search for a way to do what you are trying to achieve with Windows API or the .NET library.
Upvotes: 3