Jump to content

Damn if you do, Damn if you dont


Recommended Posts

#RequireAdmin
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=ALaunch_ZDEFTOOLBAR.ico
#AutoIt3Wrapper_Outfile=Start ALauncher.exe
#AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
$RegFile = '"' & @ScriptDir & '\ALOptions.reg"'
$RegKey = '"HKEY_CURRENT_USER\Software\Advanced Launcher"' ;Quoted already
RunWait(@WindowsDir & "\regedit.exe /S " & $RegFile) ;File to registry
RunWait(@WindowsDir & "\regedit.exe /E " & $RegFile & ' ' & $RegKey) ;Export to file
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run", "Advanced Launcher loader", "REG_SZ", @ScriptFullPath)
RunWait(@ComSpec & ' /c regedit /e "' & $RegFile & '" "HKEY_CURRENT_USER\Software\Advanced Launcher"', '', @SW_HIDE)
ShellExecute (@ScriptDir & "\ALaunch.exe")

I have a problem with this script and many others.

When i include "#requireAdmin" script DOES get registry saved into local file.
How ever, the ALaunch.exe is executed strangly and does not seem to pass correct execution level or credentials further down (ALaunch.exe is a laucher of other programs)

When i remove "#requireAdmin" everything works as it should (i mean programs that are executed by the ALaunch.exe  launcher work fine) (by "fine" i mean i am able to drag and drop into UI of what ever program i am trying to run.)

 

I set execution level to default and as invoked (when compiling the script)
I also tried to just "run" instead of "shellexecute" but the result is the same.

The only thing that makes a difference is removing the #requireadmin. But without it, script will not save/write registry.

 

What do i do ?

Link to comment
Share on other sites

You can't drag/drop files onto a program that has higher access when using it with a program with lower access. If you run a program with admin credentials, then run Windows Explorer as a regular user, you won't be able to drag and drop from Explorer to the higher execution level program. That's Windows security and has absolutely nothing whatever to do with AutoIt.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

You can probably use a more meaningful title. That's would help other users in the future or even you could get help faster.

 

Saludos

Link to comment
Share on other sites

  • Moderators

@tonycst Danyfirex is quite right. Please give your threads meaningful titles in the future.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Will using RunAsWait on your regedit lines work without #RequireAdmin?  In other words, elevate your regedit lines instead of your whole script.

Edited by aleph01

Meds.  They're not just for breakfast anymore. :'(

Link to comment
Share on other sites

Seeing as how you're writing to HKCU, there's no need to use #RequireAdmin anyways. Secondly, there's a RegWrite command in AutoIt so you don't need to use Regedit to write where you're writing, so you don't need to be an admin to run this script.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

2 hours ago, BrewManNH said:

Seeing as how you're writing to HKCU, there's no need to use #RequireAdmin anyways. Secondly, there's a RegWrite command in AutoIt so you don't need to use Regedit to write where you're writing, so you don't need to be an admin to run this script.

Without #RequireAdmin it does not work. IF i look at the script, i wont find problem with it. Different story when i actually run it.

Passing command directly to regedit is far simpler then writing several lines of code to read/write each key in the tree.
Not to mention i never know how many keys are there and what are their names. So i just save entire tree and all subtrees with one simple line of code that DOES NOT seem to work without #RequireAdmin even thou my @Username is Administrator.

So the topic makes perfect sense. If i specify #RequireAdmin, script saves registry but sets up an issue with elevated execution level for programs that the i use launcher to execute.
If remove #RequireAdmin, scrip does not save registry files but it does pass on the execution level correct down to programs that are executed by the launcher.

So damn if you do and damn if you dont. Its not working either way.

I never had these problems with earlier OS's like XP or 7. But since i upgraded to 10, those issues became standard.
Is it because i use Administrator account instead of regular user ? Or is it because execution level passed down from one program to another has to match all the way to the end application or else it wont work right ?

 

I make scripts that launch another programs that launch another programs, so i always have a middle man in the process of executing what ever program i need to use.
How ever, the middle man (the launcher) if executed without autoit scripts (just clicking it or even using a batch command line) works fine all the way. I only have problems when i use autoit.

 

I suspect that windows 10 does not like access level fluctuation along the process of execution. Cant think of anything else :( i tried everything.

Edited by tonycst
Link to comment
Share on other sites

So what i really want to know is what is the difference with passing execution  level down the road ?

Seems like "none" vs default or even "as envoked" seems to work, even registry gets written as expected.

I confirmed with all of my scripts i had written with #RequireAdmin that without #RequireAdmin and executionlevel set to NONE works gets registry files written and drag'n drop working. "none" should be default option when script is compiled, isnt it ?

 

I guess this is SOLVED now

Edited by tonycst
solved
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...