Sign in to follow this  
Followers 0
HockeyFan

RunAsSet

10 posts in this topic

Help!! :)

I'm running a script that uses the RunAsSet command to us Administrative rights while running the script, but when when it is launched when a non-admin user is logged in, the called application fails. If I'm logged in as the administrator, it works perfectly.

Does anyone have any ideas as to what is going wrong?

Thanks. :">

Share this post


Link to post
Share on other sites



When the script is run, it's Windows XP SP1.

Where can I find "Open Bugs"?

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

v3 Bug Reports

shouldn't be a problem then if useing SP1

Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

post your script.. I have used runasset alot and have figured out how it works fairly well


Share this post


Link to post
Share on other sites

post your script.. I have used runasset alot and have figured out how it works fairly well

<{POST_SNAPBACK}>

Here's my code...

RunAsSet("Homer", @Computername, "**********")
If FileExists("C:\Software\ePOAgent") Then
    FileMove("C:\Windows\Temp\XPSP2\FramePkg.exe", "C:\Software\ePOAgent\FramePkg.exe", 1)
Else
    DirCreate("C:\Software\ePOAgent")
    FileMove("C:\Windows\Temp\XPSP2\FramePkg.exe", "C:\Software\ePOAgent\FramePkg.exe", 1)
EndIf
;Check to see if Agent has already been installed. If so, uninstall and reinstall to verify proper connectivity.
$result = FileExists("C:\Program Files\Network Associates\Common Framework\FrmInst.exe")
If $result = 0 Then;0=failure, does not exist.
;If file does not exist, install FramePkg.exe (without embeded Homer credentials...plain FramePkg.exe from ePO server).
    SplashTextOn("McAfee ePolicy Agent", "" & @CR & "Installing McAfee ePO Agent software." & @CR & "" & @CR & "Please wait...", 400, 125, -1, -1, 0, "", 14, 400)
    Sleep(3000)
    SplashOff()
    Run("C:\Software\ePOAgent\FramePkg.exe /install=agent", "C:\Software\ePOAgent", @SW_SHOW)
    WinWait("McAfee Agent and Updater Setup", "Setup completed successfully.")
    ControlClick ("McAfee Agent and Updater Setup", "Setup completed successfully.", 2, "Left", 1)
    RunWait("C:\Program Files\Network Associates\Common Framework\cmdagent.exe /p /e /c", "C:\Program Files\Network Associates\Common Framework", @SW_SHOW)
Else;If Agent is already installed.
    SplashTextOn("McAfee ePolicy Agent", "" & @CR & "Uninstalling McAfee software FrameServices (ePO Agent)." & @CR & "" & @CR & "Please wait...", 500, 125, -1, -1, 0, "", 14, 400)
    Sleep(3000)
    SplashOff()
    Run("C:\Program Files\Network Associates\Common Framework\FrmInst.exe /ForceUninstall", "C:\Program Files\Network Associates\Common Framework", @SW_SHOW)
    WinWait("McAfee Agent and Updater Setup", "Setup completed successfully.")
    ControlClick ("McAfee Agent and Updater Setup", "Setup completed successfully.", 2, "Left", 1)
    SplashTextOn("McAfee ePolicy Agent", "" & @CR & "Installing new McAfee ePO Agent software." & @CR & "" & @CR & "Please wait...", 400, 125, -1, -1, 0, "", 14, 400)
    Sleep(3000)
    SplashOff()
    Run("C:\Software\ePOAgent\FramePkg.exe /install=agent", "C:\Software\ePOAgent", @SW_SHOW)
    WinWait("McAfee Agent and Updater Setup", "Setup completed successfully.")
    ControlClick ("McAfee Agent and Updater Setup", "Setup completed successfully.", 2, "Left", 1)
    RunWait("C:\Program Files\Network Associates\Common Framework\cmdagent.exe /p /e /c", "C:\Program Files\Network Associates\Common Framework", @SW_SHOW)
EndIf

When I run this when logged in as a poweruser, the Mcafee installs fail. They succeed when I run when logged in as Admin.

Thanks for you Help. :)

Share this post


Link to post
Share on other sites

When I run this when logged in as a poweruser, the Mcafee installs fail.  They succeed when I run when logged in as Admin.

Thanks for you Help.  :)

<{POST_SNAPBACK}>

You are not really clear about what is failing or what the errors are you get.

Could it be that he Power user id not allowed to Move the file?

RunAsSet() only changes the credentials for the programs shelled by Run() & RunWait()

If that is the case you can have the script start itself first to make the whole script run under the admin credentials... something like:

AutoItSetOption("RunErrorsFatal", 0) 
AutoItSetOption("TrayIconHide", 1) 
Break(0)
$USERNAME = "Administrator"
$PASSWORD = "Secret"
$RUN = 0      ; run indicator 
; retrieve the cycle from commandline
If $CMDLINE[0] = 1 Then $RUN = $CMDLINE[1]
If $RUN = 0 Then
   RunAsSet($USERNAME, @ComputerName, $PASSWORD)
   Run('"' & @ScriptFullPath & '" " 1"') 
   If @error Then MsgBox(4096+32,"Error", "Error starting under admin mode")
   Exit
EndIf
; commands go here that require Administrator rights

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

ill look at it when i get home... but how far does it get before it fails...

wat error msg do you get?

also,.. make sure to put the runasset() command at the end to log the admin out

aslo try using the optional flag at the end of the runasset command... try all of the different flags

I personally like my workaround for starting a script with admin more that the command line one, but Jdebs is more "correct"

mine solution

$UserName = "username"

$Password = "password"

$fulldomainname = "Domain"

If ClipGet() <> "tr1gg3r" Then

run( "net use h: \\gc\" & @UserName )

ClipPut( "tr1gg3r")

RunAsSet($UserName, $FullDomainName, $Password, 2)

Run( Prog here you want to run as admin , "", @SW_HIDE)

Exit

EndIf

; Admin Priviledged code here

Runasset()

Clipput( "not tr1gg3r" )

Edited by Wus

Share this post


Link to post
Share on other sites

You are not really clear about what is failing or what the errors are you get.

Could it be that he Power user id not allowed to Move the file?

RunAsSet() only changes the credentials for the programs shelled by Run() & RunWait()

If that is the case you can have the script start itself first to make the whole script run under the admin credentials... something like:

AutoItSetOption("RunErrorsFatal", 0) 
AutoItSetOption("TrayIconHide", 1) 
Break(0)
$USERNAME = "Administrator"
$PASSWORD = "Secret"
$RUN = 0      ; run indicator 
; retrieve the cycle from commandline
If $CMDLINE[0] = 1 Then $RUN = $CMDLINE[1]
If $RUN = 0 Then
   RunAsSet($USERNAME, @ComputerName, $PASSWORD)
   Run('"' & @ScriptFullPath & '" " 1"') 
   If @error Then MsgBox(4096+32,"Error", "Error starting under admin mode")
   Exit
EndIf
; commands go here that require Administrator rights

<{POST_SNAPBACK}>

JdeB,

Thanks for the info. :evil:

Since I'm new to this scripting stuff, would you be so kind as to explain what the $CMDLINE[0] command is all about? If you don't have the time, then could you recommend somewhere where I could read up on this? I'm so confused!! :)

I appreciate your help.

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

JdeB,

Thanks for the info.   :evil:  

Since I'm new to this scripting stuff, would you be so kind as to explain what the $CMDLINE[0] command is all about?  If you don't have the time, then could you recommend somewhere where I could read up on this?  I'm so confused!! :)

I appreciate your help.

<{POST_SNAPBACK}>

$CMDLINE[0] will contain the number of commandline parameters defined on the commandline. $CMDLINE[1] will contain the first parameters ...etc Edited by JdeB

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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