Jump to content
Sign in to follow this  
rludiker

Running from remote drive as another user

Recommended Posts

rludiker

Hello all,

Long time scripter, newborn autoiter. I have been using the heck out of this program, and I love it. I have run into a minor issue, and I am looking for a work around. I began using autoit so that I can execute administrative functions simply by directing the user to appropriate compiled script.

I am attempting to execute a simple command line argument in my script with runas admin. It works great when ran from a local drive. However, when I am trying to execute the script from a remote drive, I am given path not found errors. Since the script would not work from a mapped drive (the admin is not logged in) I gave the full UNC path within. I am still getting the same path not found error.

Can anyone provide a work around that will allow me to runas from a remote drive?

TIA!

Share this post


Link to post
Share on other sites
blademonkey

Hello all,

Long time scripter, newborn autoiter. I have been using the heck out of this program, and I love it. I have run into a minor issue, and I am looking for a work around. I began using autoit so that I can execute administrative functions simply by directing the user to appropriate compiled script.

I am attempting to execute a simple command line argument in my script with runas admin. It works great when ran from a local drive. However, when I am trying to execute the script from a remote drive, I am given path not found errors. Since the script would not work from a mapped drive (the admin is not logged in) I gave the full UNC path within. I am still getting the same path not found error.

Can anyone provide a work around that will allow me to runas from a remote drive?

TIA!

there are several issues there. you will have to map to a drive (as the admin) to do anykind of run() runwait() functions in my experience unless it is an exe and you do not need to specify arguments (switches).

Obviously, different users have different mapped drives, so if you map a network drive X: for user1 then you will have to do the same for user2 or even admin (network or local). That seems like a sequence issue.

Remember that a runasset only applies to run() and runwait()

so for instance, if you're logged in as user1 and you compile and run the following code

runasset("admin","password","domain")
filedelete($file1)
filecopy($file2, $target)
runwait(@comspec & ' /c ' & 'del ' &$file1)
runasset()

then filedelete and filecopy are done as user1 but the runwait is executed as "admin"


---"Educate the Mind, Make Savage the Body" -Mao Tse Tung

Share this post


Link to post
Share on other sites
rludiker

Hi BladeMonkey. Thanks for the information. I understand what your saying, however I am not stuck on the mapped drive part, I am stuck on the remotely executed part. Here is a sample of my code, maybe that will help explain a little better...

Dim $UserName, $DomainName, $Password
$UserName = "admin"
$DomainName = "domain"
$Password = "password"
RunAsSet ( $UserName, $DomainName, $Password )
Run(@ComSpec & " /k " & '\\UNC\path\that\is\readable\by\all\subinacl.exe /subkeyreg "HKEY_LOCAL_MACHINE\SOFTWARE\Citrix" /grant="Domain Users"=F', "", @SW_HIDE)

Simple enough... This code works as expected when executed from the C drive of any computer. It will grab & use the needed subinacl file from the UNC path. However - if the compiled executable is located on a remote drive, executing it throws path not found error.

Yes, I could include the remote file by using FileInstall, or by a simple copy-use-delete, but for the way I intend to use the script I need to have all the files located on the server.

Share this post


Link to post
Share on other sites
blademonkey

here's the thing, when you do a run or runwait with the @comspec switch, it's basically opening up a cmd window (you know like -->start-->run-->cmd). the problem is not with Autoit, the problem is that cmd (or dos) does not accept UNC paths, you will HAVE to map to it.

there are several potential solutions to this, such as:

1 - you can do a filecopy("\\UNC\path\that\is\readable\by\all\subinacl.exe","c:\temp"), run or runwait from the c:\temp folder and then remove the file once more.

2 - you could elevate the autoit script to do a runas (either by special functions or a seperate autoit script) and do a drivemap to the UNC path and run it from there.

there are a ton of options, but the key is that you understand that the limitation is in DOS/CMD and not technically Autoit (autoit is just creating an instance of CMD for you).


---"Educate the Mind, Make Savage the Body" -Mao Tse Tung

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.