Sign in to follow this  
Followers 0
hendrikhe

#RequireAdmin: not able to execute script

5 posts in this topic

#1 ·  Posted (edited)

Hello,

If I open the my "GUI" program and  press "Flush DNS" button it will not execute dnsflush.exe . It only works if I remove #RequireAdmin, no error message :/

 

GUI:

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Test", 615, 437, 192, 124)
$FlushDNS = GUICtrlCreateButton("Flush DNS", 24, 56, 75, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $FlushDNS
            RunWait(@ScriptDir & '\dnsflush.exe')

    EndSwitch
WEnd

 

dnsflush.exe:

#RequireAdmin
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Outfile=dnsflush.exe
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <AutoItConstants.au3>
#include <MsgBoxConstants.au3>




MsgBox(0, "Output", "test")

 

 

 

 

Edited by hendrikhe

Share this post


Link to post
Share on other sites



#2 ·  Posted

What happens when you put #RequireAdmin in your main script?

Share this post


Link to post
Share on other sites

#3 ·  Posted

That will work, but in this case I could run the second script directly (it works if I dont execute from GUI).

But I want to add some buttons in this GUI later and some can be executed by a normal user and others will need admin.

And since the normal user will have access to this GUI and dont want this user executing Admin scripts.

Share this post


Link to post
Share on other sites

#4 ·  Posted

Just use ShellExecuteWait(@ScriptDir & '\dnsflush.exe')

Share this post


Link to post
Share on other sites

#5 ·  Posted

thats it! thank you :)

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