Jump to content

Run DriveMapAdd as a different user


lansti
 Share

Recommended Posts

Hi.

I have this program that has to be run as an administrator. For this i have created a new shortcut that runs this commando line:

Local $sUserName = "administrator"
Local $sPassword = "password"
$programPath = @ProgramFilesDir & "\folder\program.exe"
if FileExists($programPath) Then

runas($sUserName, @LogonDomain, $sPassword, 0, $programPath, @SystemDir)
Else
MsgBox(48,$MsgTitle,"Program not installed.",3)
EndIf
Exit

But i need to map a drive as this administrator user as well, and not as the logged on user.

I hoped that this would help, in the IF sentence right above runas program as administrato:

runas($sUserName, @LogonDomain, $sPassword, 0, DriveMapAdd("i:", "\\server\share", 0, "username to share", "password to share"))

But it seems that it map this drive as the logged on user...

I can verify that by opening CMD with the administrator user and "net use". no mapped drive will appear. if i manually map the drive in this CMD, the program works, and i can verfy the mapping in the same CMD

Any suggestions?

Link to comment
Share on other sites

Do you already have a connection to that same server as the logged on user? You can't make concurrent connections to the same server with different credentials.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...