Jump to content

Very Basic Problem - re. RunAs


Recommended Posts

Hello All,

Yes I am very new to AutoIt and like the rest I ask that you forgive me for this if it's asked a thousand times.

But basically I've tried searching the forums and found what I thought was the answer to my problem. But it still doesn't work.

I need to run the simple command "net time /setsntp:<servername>" but it needs to be done as an administrator.

So I found in my search the solution (or so I thought)

RunAsSet ( "admin", "MyDomain", "Password", 2 )

RunWait("cmd /c net time /setsntp:time.optusnet.com.au")

RunAsSet()

The script works perfectly ofcourse as an administrator but not otherwise. I even tried just creating a simple batch file with the command in it and running the bat file using RunAsSet but it still didn't work as a normal user.

Am I missing something?

Link to comment
Share on other sites

Is the RunAs service disabled on the computer or server? Have you tried it without Option 2? Have you doublechecked the local machine Administrator AccountName, password, and the local machine name? Using my Domain Account, in AD, I must list the UserName as "Domain\UserName" to get it work. Some of the 2003 Servers are stubborn...

Link to comment
Share on other sites

Is the RunAs service disabled on the computer or server?  Have you tried it without Option 2?  Have you doublechecked the local machine Administrator AccountName, password, and the local machine name?  Using my Domain Account, in AD, I must list the UserName as "Domain\UserName" to get it work.  Some of the 2003 Servers are stubborn...

<{POST_SNAPBACK}>

Yes! Thankyou, my first successful AutoIt script hehe

I just removed the option 2 and now it works? go figure?

Thanks for the ideas.

Link to comment
Share on other sites

Bah! Now I have another odd but hopefully simple problem.

We are using Kix login script and when I add the command in the login script to run the autoit file it doesn't work, it says "unable to execute external program, the directory name is invalid"

But if I simply run the script after the user is logged in it runs without a problem. So I don't think there's any problems with the script, but somehow the execution time is an issue?

Link to comment
Share on other sites

Ive had this very problem... I think it has to do with sharing/security and permissions on the share... also make sure you use UNC paths not mapped drives

my ultimate solution was to completely redo my login script in 100% autoIT... works fine now... though in order to access the server i need to do a runnas() admin and restart the script

refer to this this link

http://www.autoitscript.com/forum/index.ph...807entry83807

Just to make sure you understand this,.. unless your not giving a valid UNC path the rpoblem is in your permissions for the user your running the script as... or the sharing on the share...

Edited by Wus
Link to comment
Share on other sites

try it with a local admin account and specify the computer name when using RunAsSet.

RunAsSet("Administrator", @Computername, "adminpassword")

Cheers

Kurt

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Link to comment
Share on other sites

Thanks for your suggestions guys, I ended up finding the solution myself. This seems to be a very common error but the cause can be any number of things. I guess I got lucky, basically I needed to put an extra item in the RunWait line for a 'working directory'. The script is as simple as below and now it runs fine during login.

RunAsSet ( "admin", "MyDomain", "Password" )

RunWait("cmd /c net time /setsntp:server1", "\\server2\netlogon")

RunAsSet()

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...