Jump to content

Recommended Posts

I have my script running with #RequreAdmin but when I click on my Button to launch edge with a URL it opens it with a mortal edge and not Admin Edge. Im a noob so i dont really know how to script¬†ūüôÉ. The main function of this is run it as admin and when i click on my buttons they will open in admin rights already.¬†

 

#RequireAdmin
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Compile_Both=y
#AutoIt3Wrapper_UseX64=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****


#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=c:\users\user\desktop\scripts\menu.kxf
Global $Programs = GUICreate("Programs", 232, 326, -1, -1)
Global $CMD = GUICtrlCreateButton("CMD", 24, 16, 75, 25)
Global $ExitButton = GUICtrlCreateButton("Exit", 80, 288, 75, 25)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
Global $CMC = GUICtrlCreateButton("CMC", 24, 48, 75, 25)
Global $ARS1 = GUICtrlCreateButton("ARS 1", 24, 80, 75, 25)
Global $ARS2 = GUICtrlCreateButton("ARS 2", 24, 112, 75, 25)
Global $LAPS = GUICtrlCreateButton("LAPS", 24, 144, 75, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $CMD
            StartCMD ()

        Case $CMC
            StartCMC ()

        Case $ARS1
            StartARS1 ()

        Case $ARS2
            StartARS2 ()

        Case $LAPS
            StartLAPS ()

        Case $ExitButton
            Exit

    EndSwitch
WEnd

Func _ProgramFilesDir()
    Local $ProgramFileDir
    Switch @OSArch
        Case "X32"
            $ProgramFileDir = "Program Files"
        Case "X64"
            $ProgramFileDir = "Program Files (x86)"
    EndSwitch
    Return @HomeDrive & "\" & $ProgramFileDir
EndFunc   ;==>_ProgramFilesDirh

Func StartCMD ()
        ShellExecute('cmd.exe')
        WinWaitActive('CMD')
EndFunc   ;==>StartCMD

Func StartCMC ()
        ShellExecute($CMCP)
        WinWaitActive('Microsoft Endpoint Configuration Manager')
EndFunc        ;==>StartCMC

Func StartARS1 ()
    ShellExecuteWait("C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe","http://A-URL-Here")
EndFunc

func StartARS2 ()
    ShellExecute($ARS02)
EndFunc

Func StartLAPS ()
        ShellExecute($LAPSP)
        WinWaitActive('LAPS UI')
EndFunc   ;==>StartLAPS

Link to post
Share on other sites

I forgot to add i will have edge open as a normal account and when i click the button i want it to open a new edge with admin rights. im trying to do this without a .lnk to run or a bat. i just want 1 program to rule them all type thing if possible.  

Link to post
Share on other sites

Why not just use Edge profiles, for example I have my standard profile for browsing, but for Azure (we manage multiple tenants) I have a different profile for each tenant.  Each profile  Profiles are separate from each other and hold their own settings, passwords, bookmarks, history etc...  

Link to post
Share on other sites

Would suggest asking them to create a security group and deny the GPO for the techs, opening any browser with admin rights especially domain admin or helpdesk admin rights would be a risk to your organisation.

One workaround is to remove the #RequireAdmin, ask techs to run your script using "Shift+Right Click" ¬Ľ¬†¬†"Run as different user" to logon with your admin credentials, then you can choose which apps should be elevated using ShellExecute, ie.

;~ The following will run CMD with admin priviliges
ShellExecute("CMD.exe", "", "", "RunAs")
;~ This will open Edge as the user profile but not elevated
ShellExecute("MSEdge.exe")

 

Link to post
Share on other sites

Right now we do right click each program and run as admin then put our tech account info to do what we need or do this to our shortcut to do it faster "%windir%\system32\runas.exe /savecred /user:domain\techaccount". Right now im just trying to learn and maybe help out others with my script. To me its weird that #Require Admin is not elevating Edge when I click it. I can maybe also just do this $ARS ="C:\Temp\ARS1.lnk" and just put my shortcuts there and it can run that way but I wanted it all run in the script itself.

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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...