Re: Run As Different User
Re: Run As Different User
This seems to work, but using the console and sendkeys..
VB Code:
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Sub Command1_Click()
Shell "runas.exe /profile /user:[B]administrator[/B] notepad.exe"
Sleep (1000) 'Wait for runas.exe to load
SendKeys ("[B]password[/B]" & "{ENTER}")
End Sub
in bold user and password, if you enter correct values there notepad will open
1 Attachment(s)
Re: Run As Different User
ok - below is a class that will let you emulate other windows accounts
clsNMC
VB Code:
'See attached file (note the file is a text file as i dont have vb on this comp)
and you will need to do this to impersonate the user:
VB Code:
Dim cNMC As New clsNMC
cNMC.User_Impersonate "User", "Password", "." '.=local windows account (domain)
this will make your prog have that users access to files etc
you can also run another prog as another user by:
VB Code:
Dim cNMC As New clsNMC
cNMC.User_RunAs "User", "Password",".","c:\windows\explorer.exe"
Re: Run As Different User
I faced some errors thru the defining of that code , Ps advice me how to can I define it
Re: Run As Different User
I tried to import this class into my project, and I'm getting a million errors. Anyone using this has a successful version I could use?
Re: Run As Different User
Import? Is this a VBA project you are talking about? For VBA7 compatibility all API declares has to be first converted to the new x86+x64 compatible format.
Btw, here is the final version of this class: https://github.com/Planet-Source-Cod...ter/clsNMC.cls
cheers,
</wqw>
Re: Run As Different User
This is a vb solution/project (visual studio) doing something very simple, but since I don't always having the rights to a network drive I need, I wanted to try to run the vb executable as a different user.
Re: Run As Different User
Quote:
Originally Posted by
bushmobile
The link seem to be wrong, and go to another page...
Re: Run As Different User
Quote:
Originally Posted by
Shoshana Michel
This is a vb solution/project (visual studio) doing something very simple, but since I don't always having the rights to a network drive I need, I wanted to try to run the vb executable as a different user.
Then you are using VB.Net, the given sample is for VB6
Re: Run As Different User
Quote:
Originally Posted by
LeoFar
The link seem to be wrong, and go to another page...
It is no longer valid because it was posted on year 2006.
There is a stored version here and a new page here.
Re: Run As Different User
Quote:
Originally Posted by
Eduardo-
It is no longer valid because it was posted on year 2006.
There is a stored version
here and a new page
here.
Thank.