Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

System.Diagnostics.Process() doesn't run with credentials specified

Status
Not open for further replies.

lmichiel

MIS
Mar 27, 2001
19
NL
Hi

I'm trying to create a program which starts another one. Because the target application is located on our domain and the pc it must run on isnt, I have to pass the appropiate user credentials but no success. What am I doing wrong? The code I'm using is:

Public Sub ShellandWait(ByVal ProcessPath As String, ByVal ProcessArgs As String)
Dim objProcess As System.Diagnostics.Process
Try
objProcess = New System.Diagnostics.Process()
objProcess.StartInfo.FileName = ProcessPath
objProcess.StartInfo.Arguments = ProcessArgs
objProcess.StartInfo.UserName = "accountname"
Dim pw As New System.Security.SecureString
pw.Clear()
For Each ch As Char In "password"
pw.AppendChar(ch)
Next
objProcess.StartInfo.Password = pw
objProcess.StartInfo.Domain = "mydomain"
objProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden
objProcess.StartInfo.UseShellExecute = False
objProcess.Start()

'Wait until the process passes back an exit code
objProcess.WaitForExit()

'Free resources associated with this process
objProcess.Close()
Catch
MessageBox.Show("Could not start process " & ProcessPath, "Error")
End Try
End Sub

cheers
Leo
 
change:
Code:
Catch
            MessageBox.Show("Could not start process " & ProcessPath, "Error")
To:
Code:
Catch exc As Exception
            MessageBox.Show("Could not start process " & ProcessPath, "Error: " & exc.message)

might help find the issue ;)

-Rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
Hi Rick

Thanks but no go. Still the same problems

cheers
Leo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top