Jump to content

#RequireAdmin If Statement


 Share

Recommended Posts

I believe that by default you can't make the #RequireAdmin an option-able thing?

 

I am trying to make it where the user has a choice to run the program as admin or not with an INI (Settings) in the program.

 

Func _RunAsAdminCheck()
    $SettingsData = IniReadSection(@ScriptDir & "\Data\Settings.ini", "Settings")
    If $SettingsData[1][1] = "1" Then
        IniWrite(@ScriptDir & "\Data\Settings.ini", "Settings", "1", "0")
        MsgBox(0, "Settings...", "Admin required set to inactive. Effects will take place after restarting the program.")
    Else
        IniWrite(@ScriptDir & "\Data\Settings.ini", "Settings", "1", "1")
        MsgBox(0, "Settings...", "Admin required set to active. Effects will take place after restarting the program.")
    EndIf
EndFunc

 

The above is what fires when the user clicks a button and enables or disabled admin requirement.

 

And then I have this at the start of the script.

 

$SettingsData = IniReadSection(@ScriptDir & "\Data\Settings.ini", "Settings")

 

If $SettingsData[1][1] = "1" Then
     TrayItemSetState($TrayMenuSettingsRunAsAdminItem, $TRAY_CHECKED)
     #RequireAdmin
Else
     TrayItemSetState($TrayMenuSettingsRunAsAdminItem, $TRAY_UNCHECKED)
EndIf

 

But whether or not the $SettingsData[1][1] = 1 or 0 it always runs the #RequireAdmin. Is there a way around this or no?

 

Thanks!

MCR.jpg?t=1286371579

Most recent sig. I made

Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic

Link to comment
Share on other sites

Ah, perfect. Thank you sir.

MCR.jpg?t=1286371579

Most recent sig. I made

Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic

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