Adagio
Well-known member
- Joined
- Dec 12, 2005
- Messages
- 162
- Programming Experience
- Beginner
Many times I have startet a different application from my programs with other users, but now I can't get it working with a local user
Here's the situation: On a server we have created a local user (not administrator), that is allowed to run the program needed. If we log in as a different user, right click on the file and selects "run as" and writes the local user name and password, the program runs as it should
But when I do the same in my Vb.net program it fails with "The directory name is invalid"
Here's the code I have:
If I use our domain administrator or a different domain user (not Admin) it works just fine. I have tried setting domain both to nothing and to the name of the server it runs on, all with the same result
TheTimer.exe is just a vb.net application that doens't require anything and it is using Framework 2.xxx. The directory it is in, is a directory everybody has access to
I have done a lot of searching for the error message, but nothing useful has come up yet
Anybody who has any idea what the problem could be?
Here's the situation: On a server we have created a local user (not administrator), that is allowed to run the program needed. If we log in as a different user, right click on the file and selects "run as" and writes the local user name and password, the program runs as it should
But when I do the same in my Vb.net program it fails with "The directory name is invalid"
Here's the code I have:
VB.NET:
Imports System.Security
Public Class frmRunAsAdministrator
Private password As New SecureString
Private user As String = "superman"
Private fileName As String = "C:\Temp\TheTimer.exe"
Private domain As String = Nothing
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
SetPassWord()
Process.Start(fileName, user, password, domain)
Catch ex As Exception
Dim msg As String = "Fejl opstod ved start af program" & vbCrLf & ex.Message
If Not ex.InnerException Is Nothing Then
msg = msg & vbCrLf & ex.InnerException.ToString
End If
MsgBox(msg, MsgBoxStyle.Critical)
Finally
Application.Exit()
End Try
End Sub
Private Sub SetPassWord()
Dim pass As String = "MySuperPassword"
Dim num As Integer = 0
Dim length As Integer = pass.Length
Do While (num < length)
Dim c As Char = pass.Chars(num)
password.AppendChar(c)
num += 1
Loop
End Sub
End Class
If I use our domain administrator or a different domain user (not Admin) it works just fine. I have tried setting domain both to nothing and to the name of the server it runs on, all with the same result
TheTimer.exe is just a vb.net application that doens't require anything and it is using Framework 2.xxx. The directory it is in, is a directory everybody has access to
I have done a lot of searching for the error message, but nothing useful has come up yet
Anybody who has any idea what the problem could be?