elawady Posted February 16, 2010 Posted February 16, 2010 when i write script to run it in startup have this #RequireAdmin message every startup and it make me crazy i need something to run script like that statements $reg = IniRead ( @AppDataDir&"\count.ini", "info", "reg","off" ) If $reg = "off" Then #RequireAdmin FileCopy(@ScriptFullPath,@ProgramFilesDir&"\counter\"&@ScriptName) RegWrite("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run","counter","REG_SZ",@ProgramFilesDir&"\counter\"&@ScriptName&" \count") IniWrite ( @AppDataDir&"\count.ini", "info", "reg" ,"on") EndIf statements ........ func _function() #RequireAdmin statements endfunc when change setting only the #RequireAdmin work
ProgAndy Posted February 16, 2010 Posted February 16, 2010 Does your script need Admin-Rights only once? Then take all Admin operations and put them in a separate script. This will run with #requireAdmin (FileInstall, ShellExecuteWait, FileDelete, check an Ini value if it succeeded) *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes
elawady Posted February 16, 2010 Author Posted February 16, 2010 any way to do it in 1 script not many and use fileinstall
ProgAndy Posted February 16, 2010 Posted February 16, 2010 Put everything in one script, use commandline-parameters to choose the action. Run the admin-commands with ShellExecute and Verb runas: Switch $CMDLINE[0] Case 1 If $CMDLINE[1] = "-installadmin" ; do admin tasks here Exit ElseIf $CMDLINE[1] = "-uninstalladmin" ; do Uninstall here Exit EndIf EndSwitch ; normal script If $DO_ADMIN_TASKS Then ShellExecuteWait(@AutoItExe, $CMDLINERAW & " -installadmin", @WorkingDir, "runas") ; $CMDLINERAW is needed that it works with uncompiled scripts, too. ... EndIf *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes
elawady Posted February 16, 2010 Author Posted February 16, 2010 (edited) thankyou it's work but in the end i used fileinstall Edited February 16, 2010 by elawady
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now