Jump to content

RunAs not working properly


damon
 Share

Recommended Posts

I am having problems getting a script to run with admin rights. I have 3 different passwords due to different computers not receiving network updates/pushes to have admin password updated to one consistant.

Everytime I run the script it does nothing and exits, so i put in some msgbox's to find out what is going on, and the return with "0" on all three. I have Windows SP3 on the computer and have read in other post that people are thinking that it is causing problems, I am not even able to get one run much less the 32 that they get before it quits working.

I have changed the user name and passwords for this forum due to security reasons, any help would be appreciated.

If $CmdLine[0] > 0 Then
    If $CmdLine[1] = "/UpdateOffice" Then UpdateOffice()
    Exit
EndIf
Local $user = "admin"
Local $pass = "password"
Local $pass2 = "password2"
Local $pass3 = "password3"
If IsAdmin () = 0 Then
$run1 = RunAs ( $user, @ComputerName, $pass, 0,@ScriptFullPath & " /UpdateOffice")
MsgBox (0,"",$run1)
If  $run1 = 0 Then
  $run2 = RunAs( $user, @ComputerName, $pass2, 0,@ScriptFullPath & " /UpdateOffice")
  MsgBox (0,"",$run2)
  If $run2 = 0 Then
   $run3 = RunAs ( $user, @ComputerName, $pass3, 0,@ScriptFullPath & " /UpdateOffice")
   MsgBox (0,"",$run3)
   If $run3 = 0 Then
   MsgBox (0,"",$run3)
    Exit
   EndIf
  EndIf
EndIf
EndIf
UpdateOffice()

UpdateOffice is calling the function with a gui that I built. I can attach it if I need but I seen the above being the problem.

thanks,

Damon

It always amazes me how one little thing can cause so much havoc

Link to comment
Share on other sites

yes I do Compile it, I test on a separate computer from what I code on that does not have autoit installed on it. I have to due to the fact I need to make sure I am logged on as a user. I have used this in many other scripts in the past with no problems but for some reason it is not running or coming back with a PID, I have changed/checked the admin password to make sure it is the same as my variable in my code,

Visually looking, do you see anything wrong with my code? This will give me a baseline of trouble shooting possibilities.

It always amazes me how one little thing can cause so much havoc

Link to comment
Share on other sites

I can't get that script to run as is on Windows 7 or XP. I did get it to work with my domain credentials, but not with local administrator credentials. I added a few message boxes before I compiled it to see where in the script it was.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

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

×
×
  • Create New...