Sign in to follow this  
Followers 0
ScottMayo

Network drives

5 posts in this topic

I am new to AutoIt (was just told about it). I have a program that has to be run as an administrator on the computer. I really don't want to set all my users up as administrators on the computers. After reading and hearing about AutoIt, I thought it would do what I want, but I have been unsuccessful at getting anything to work. Maybe someone can guide me in the right direction. Here is the script that I have:

SCRIPT1

local $user = "username"

local $domain = "domain"

local $passwd = "password"

RunAsSet($user, $domain, $passwd)

Run ("s:\test.exe")

The user 'username' is in the administrative group on this local machine and if he logs in then he can run the test.exe from the S: drive just fine, but when I run this script then it says that it cannot find the path. I thought that maybe I actually had to re-map the drive so I tried putting in:

DriveMapAdd("s:", "\\server\share")

That did not work either. The strange thing is that if I take off the RunAsSet command, then it runs the test.exe file just fine. That makes no sense to me because the username, domain, and password that are set are the exact ones that I am logged onto the computer with.

Thanks for any info. I could be way off since I just started trying to use this scripting tool

Scott

Share this post


Link to post
Share on other sites



When you run as another user, login scripts are not run and drive mappings are not reinstated.

Try this:

local $user = "username"
local $domain = "domain"
local $passwd = "password"
RunAsSet($user, $domain, $passwd)
Run (@comspec & " /c net use s: \\server\share && S:\test.exe", @WindowsDir, @SW_MINIMIZE)

This runs a command prompt (minimized) which maps the drive and then runs your program. Since the drive was mapped in the same environment, it will be available to the program.


BlueBearrOddly enough, this is what I do for fun.

Share this post


Link to post
Share on other sites

When you run as another user, login scripts are not run and drive mappings are not reinstated.

Try this:

local $user = "username"
local $domain = "domain"
local $passwd = "password"
RunAsSet($user, $domain, $passwd)
Run (@comspec & " /c net use s: \\server\share && S:\test.exe", @WindowsDir, @SW_MINIMIZE)

This runs a command prompt (minimized) which maps the drive and then runs your program. Since the drive was mapped in the same environment, it will be available to the program.

Thank you. That worked. I messed with this for about a whole day and just gave up. I did not realize that it had to be all in the same command. I had even tried created a regular batch file that mapped the drive and ran the program and had an AutoIt script that ran the batch file as an administrator, but that had not worked either. I was thinking that if the batch file ran as an administrator, that the commands in side it would have also, but I guess I was wrong.....which I usually am. :)

Thanks again.

Scott

Share this post


Link to post
Share on other sites

Well, the commands don't all have to be on the same line. Your batch file idea should have worked. However, with switching users like this it is hard to tell what the environment is going to be like, which is why I just ran it all from one line in AutoIt. Your batch file probably didn't work because of some permissions issue which probably wasn't very obvious.


BlueBearrOddly enough, this is what I do for fun.

Share this post


Link to post
Share on other sites

Well, the commands don't all have to be on the same line. Your batch file idea should have worked. However, with switching users like this it is hard to tell what the environment is going to be like, which is why I just ran it all from one line in AutoIt. Your batch file probably didn't work because of some permissions issue which probably wasn't very obvious.

Maybe, but considering I was logged in as the same user that is in the script then it should not have mattered. I am just glad it is working. I can see where AutoIt may come in very handy here at school.

Thanks again.

Scott

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  
Followers 0