Hello everyone. I have problems with executing a process in a webservice method on a Windows Server 2003 machine. Here is the code:
Dim target As String = "C:\dnscmd.exe"
Dim fileInfo As System.IO.FileInfo = New System.IO.FileInfo(target)
If Not fileInfo.Exists Then
Throw New System.IO.FileNotFoundException("The requested file was not found: " + fileInfo.FullName)
End If
Dim startinfo As New System.Diagnostics.ProcessStartInfo("C:\dnscmd.exe")
startinfo.UseShellExecute = False
startinfo.Arguments = "\\MYCOMPUTER /recordadd mydomain.no " & dnsname & " CNAME myhost.mydomain.no"
startinfo.UserName = "user1"
Dim password As New SecureString()
For Each c As Char In "secretpassword".ToCharArray()
password.AppendChar(c)
Next
startinfo.Password = password
Process.Start(startinfo)
I know the process is being executed because i use processmonitor.exe on the server and it tells me that c:\dnscmd.exe is called with the right parameters Full command line value from procmon is: "C:\dnscmd.exe" \MYCOMPUTER /recordadd mydomain.no mysubdomain CNAME myhost.mydomain.no The user of the created process on the server is NT AUTHORITY\SYSTEM.
BUT, the dns entry will not be added! Here is the weird thing: I KNOW the user (user1) I authenticate with has administrative rights (it's the same user I use to log on the machine with), but the user of the process in procmon says NT AUTHORITY\SYSTEM (which is not the user i use to authenticate).
Weirdest: If i log on to the server, copy the command line value read from the procmon logging, and paste it in a command line window, it works!
Reading procmon after this shows that user1 owns the dnscmd process.
Why doesn't user1 become owner of the process started with system.diagnostics.process?
Is the reason why the command doesn't work?