Jump to content

Recommended Posts

@AdamUL

I have no words to thank you, I'm struggling for a long time for a solution to this problem.

The closest I got is use runasspc, but it flashes a terminal every time it run, and popup a window with license info at random intervals.

Your solution works like a charm.

Some programs like coretemp don't run under restricted account, with your script I can launch It at login like it should.

Share this post


Link to post
Share on other sites

Hi,

I tried using this script for the same exact reason as jsnyder213 however it's not working for me.

I get "ERROR!", "Unable to run under administrator account."

 

Global $sAdminUser = "admin"
Global $sAdminPassword = "password"
Global $sDomain = @ComputerName
Global $iLogOnFlag = 0
Global $sParameters = ""

;Elevate with the Admin account.
If @UserName <> $sAdminUser And Not IsAdmin() Then
    $sParameters = ""
    If Not @Compiled Then
        $sParameters = ' "' & @ScriptFullPath & '"'
    EndIf

    If RunAs($sAdminUser, $sDomain, $sAdminPassword, $iLogOnFlag, @AutoItExe & $sParameters) Then
        Exit
    Else
        Exit MsgBox(16 + 262144, "ERROR!", "Unable to run under administrator account.")
    EndIf
EndIf

;Run with Admin Token in Windows Vista and Higher.
If @UserName = $sAdminUser And Not IsAdmin() And Not StringRegExp(@OSVersion, "_(XP|200(0|3))") Then
    $sParameters = ""
    If Not @Compiled Then
        $sParameters = '"' & @ScriptFullPath & '"'
    EndIf

    If ShellExecute(@AutoItExe, $sParameters, "", "runas") Then
        Exit
    Else
        Exit MsgBox(16 + 262144, "ERROR!", "Unable to elevate to Admin due to UAC.")
    EndIf
EndIf

;Put rest of the script here.

Run(@ScriptDir & "\sw2016.exe")

 

Share this post


Link to post
Share on other sites

Is the admin account you are using a local account or a domain account?  Confirm that the user is in the local Administrators group.  This error usually means there is an issue with the account.  

 

Adam

 

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

×
×
  • Create New...