How do I user VB.NET to Open Command Prompt, Call .bat File, and Send Parameters to .bat fil
Greetings,
I am Creating an ASP.NET application that our users may go to to unlock a locked out computer. Once the user supplies the IP Address and UserName they click the unlock button. The button Runs VB.Net code that takes the IP Address and UserName, looks at the first 2 octets of the IP and from that chooses which .bat file to run. All of that works great.
The problem I am having is when I try to open the command prompt to call the .bat file nothing happens. I've searched and found many helpful ways but none seem to support passing the IP and UserName to the .bat file. the .bat file calls a .vbe that logs onto the remote computer as admin and then calls another .bat which calls the unlocking .vbe This is about the only way we have found to remotely unlock users since we do not use AD/LDAP. I'll supply a code snippet to demonstrate how the format works.
Dim IPAsStringDim personAsStringDim FirstOctetsAsStringDim goAs System.Diagnostics.ProcessStartInfo =New System.Diagnostics.ProcessStartInfo("cmd.exe")
go.UseShellExecute =
Falsego.RedirectStandardInput =
Truego.RedirectStandardOutput =
Truego.RedirectStandardError =
Truego.WorkingDirectory =
"c:\\Scripts\\"IP = IPAddress.Text'Gets I.P. from text boxperson = UserName.Text
'Gets user name from text boxFirstOctets = Left(IP, 6)
'Grabs only the first 6 characters of the I.P. address If FirstOctets = ("10.20.")ThenMsgBox(
"Calling Program") Dim procAs System.Diagnostics.Process = System.Diagnostics.Process.Start(go) Dim sinAs System.IO.StreamWriter = proc.StandardInput Dim soutAs System.IO.StreamReader = proc.StandardOutputsin.WriteLine(
"go20.bat " & IP & person)Thanks for any help you may be able to go.
Zach

