R
RichardCUK
Guest
I have been trying to create a 'simple' Visual Basic.net program which will allow me to run another program under a different user... basically simulate the functionality of RUNAS.
I have tried using a CreateProcessWithLogonW command
retcode = CreateProcessWithLogonW(g_strUserName, g_strDomain, g_strPassword, _
LOGON_WITH_PROFILE, 0&, "notepad.exe", "c:\", 0&, 0&, si, pi)
And
Dim myProcess As System.Diagnostics.ProcessStartInfo
myProcess = New System.Diagnostics.ProcessStartInfo()
Dim password As Security.SecureString
password = New Security.SecureString
g_strUserName = "CinAccess"
g_strPassword = "test"
Dim c As Char
For Each c In g_strPassword
password.AppendChar(c)
Next c
myProcess.Password = password
myProcess.UserName = g_strUserName
myProcess.LoadUserProfile = True
myProcess.UseShellExecute = False
myProcess.WorkingDirectory = path
myProcess.RedirectStandardOutput = True
Try
Process.Start("\notepad.exe", g_strUserName, password, g_strDomain)
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical, "WARNING!")
End Try
Both of these ways of doing things have given me the following error:
---------------------------
WARNING!
---------------------------
The directory name is invalid
---------------------------
OK
---------------------------
I have spent quite a bit of time looking on the internet and nothing suggested as worked. If anyone has any suggestions then I would really appreciate it.
Thank you in advance
Richard
Continue reading...
I have tried using a CreateProcessWithLogonW command
retcode = CreateProcessWithLogonW(g_strUserName, g_strDomain, g_strPassword, _
LOGON_WITH_PROFILE, 0&, "notepad.exe", "c:\", 0&, 0&, si, pi)
And
Dim myProcess As System.Diagnostics.ProcessStartInfo
myProcess = New System.Diagnostics.ProcessStartInfo()
Dim password As Security.SecureString
password = New Security.SecureString
g_strUserName = "CinAccess"
g_strPassword = "test"
Dim c As Char
For Each c In g_strPassword
password.AppendChar(c)
Next c
myProcess.Password = password
myProcess.UserName = g_strUserName
myProcess.LoadUserProfile = True
myProcess.UseShellExecute = False
myProcess.WorkingDirectory = path
myProcess.RedirectStandardOutput = True
Try
Process.Start("\notepad.exe", g_strUserName, password, g_strDomain)
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical, "WARNING!")
End Try
Both of these ways of doing things have given me the following error:
---------------------------
WARNING!
---------------------------
The directory name is invalid
---------------------------
OK
---------------------------
I have spent quite a bit of time looking on the internet and nothing suggested as worked. If anyone has any suggestions then I would really appreciate it.
Thank you in advance
Richard
Continue reading...