So I've been unable to figure this out...
All it gives me is "The command completed successfully" in the textbox
when in fact it hasn't.. sure the command ran, but it could not find the file and did not execute.
The other issue I'm having is with running psexec even with double quotes it was not executing the remote file, while I know it exists and the path/name is correct.
I tried to add cmd /k to be able to keep the window open to see errors but that didn't help.
Code:
If Not ipMWS.Text = "" Then
Dim dir As New IO.DirectoryInfo("\\" & ipMWS.Text & "\c$")
Dim pcaXP As New IO.DirectoryInfo("\\" & ipMWS.Text & "\c$\program files\symantec\pcanywhere\")
Dim pcaVista7and8 As New IO.DirectoryInfo("\\" & ipMWS.Text & "\c$\program files (x86)\symantec\pcanywhere\")
Dim pcaResult As String
'MsgBox("User: " & strMWSUsername & " " & "password: " & strMWSPassword)
Shell("net use \\" & ipMWS.Text & "\c$ /delete", AppWinStyle.NormalFocus)
Dim process As New Process()
Dim FileName As String = "net"
Dim Arguments As String = "use \\" & ipMWS.Text & "\c$ /USER:" & strMWSUsername & " " & strMWSPassword
Dim remoteCMD As String = "psexec.exe"
Dim pexec As New Process()
process.StartInfo.UseShellExecute = False
process.StartInfo.RedirectStandardOutput = True
process.StartInfo.RedirectStandardError = True
process.StartInfo.CreateNoWindow = True
process.StartInfo.FileName = FileName
process.StartInfo.Arguments = Arguments
process.Start()
Dim stdoutput As String = process.StandardOutput.ReadToEnd()
Dim errOutput As String = process.StandardError.ReadToEnd()
TextBox1.AppendText(stdoutput)
TextBox1.AppendText(errOutput)
If dir.Exists Then
'MsgBox("exists")
If pcaXP.Exists Then
process.StartInfo.WorkingDirectory = Environment.SpecialFolder.System
Dim args As String = "\\" & ipMWS.Text & " -u " & strMWSUsername & " -p " & strMWSPassword & " ""cmd /k c:\program files (x86)\symantec\pcanywhere\awhost32.exe"""
MsgBox(args)
process.Start(remoteCMD, args)
TextBox1.AppendText(stdoutput)
TextBox1.AppendText(errOutput)
End If
If pcaVista7and8.Exists Then
process.StartInfo.WorkingDirectory = Environment.SpecialFolder.System
Dim args As String = "\\" & ipMWS.Text & " -u " & strMWSUsername & " -p " & strMWSPassword & " ""cmd /k c:\Program Files\Symantec\pcAnywhere\awhost32.exe"""
MsgBox(args)
process.Start(remoteCMD, args)
TextBox1.AppendText(stdoutput)
TextBox1.AppendText(errOutput)
End If
If Not pcaXP.Exists And Not pcaVista7and8.Exists Then
MsgBox("Unable to run PCA")
End If
Else
MsgBox("Could not connect to share \\" & ipMWS.Text & "\C$")
End If
End If
End Subwhen in fact it hasn't.. sure the command ran, but it could not find the file and did not execute.
The other issue I'm having is with running psexec even with double quotes it was not executing the remote file, while I know it exists and the path/name is correct.
I tried to add cmd /k to be able to keep the window open to see errors but that didn't help.





