I want my Windows application built with VB.NET to open powershell onclick of button event and change directory to C:\\ and not close window.
Here is my code:
Private Sub PowershellToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles PowershellToolStripMenuItem.Click
Process.Start("powershell")
End Sub
I tried to add "-wait"
after "powershell.exe"
but that causes an error. Anyone have an idea how I can go about this?
Powershell is a command line executable. It will not attach a console normally, but if you execute it as the shell, then it should behave as you expect:
Process.Start(New ProcessStartInfo() With {.UseShellExecute = True, _
.FileName = "powershell", _
.WorkingDirectory = "C:\"})
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.