Jump to content

#RequireAdmin Not Elevating Sub-Processes


Recommended Posts

I have been using AutoIT for several years now, although mostly with Windows XP. As my company is undertaking a massive Windows 7 conversion, I find that some of the features of AutoIT do not seem to work as I would think they should, which brings about my question today...

I use the AutoIt3Wrapper with my compiled scripts and everything works well generally; however, I have a need to include two commands in an AutoIT script that have to be RunAsAdmin. I have the AutoITWrapper set as "#AutoIt3Wrapper_Res_requestedExecutionLevel=requireAdministrator" and I am prompted for UAC elevation. The commands; however, do not seem to be elevating.

RunWait(@ComSpec & ' /c bcdedit /set {default} recoveryenabled No', @HomeDrive, @SW_HIDE)
RunWait(@ComSpec & ' /c bcdedit /set {default} bootstatuspolicy ignoreallfailures', @HomeDrive, @SW_HIDE)

If I post the commands into an elevated command prompt they work correctly, but via the script they seem to be ignored.

I appreciate any ideas and/or assistance.

Thanks In Advance!!!

Link to comment
Share on other sites

  • Developers

What is the returncode from the Runwait() commands?

Maybe do some debugging by running this version:

RunWait(@ComSpec & ' /k bcdedit /set {default} recoveryenabled No', @HomeDrive)

Does it give any errors in the opened CMD window?

Jos

 

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

When looking more in depth into the issue. The error is BCDEDIT cannot be found. If I run a CMD from the script, it cannot see BCDEDIT in the C:\Windows\System32\ folder, whereas if I just run a CMD from Start>Run I can see it in the C:\Windows\System32\ folder. I did find that in both CMD windows I could find the executable at: @WindowsDir & 'winsxsamd64_microsoft-windows-b..iondata-cmdlinetool_31bf3856ad364e35_6.1.7601.17514_none_e6510234bbcb2a8c, so I pointed the script to that location:

RunWait(@ComSpec & ' /c ' & @WindowsDir & '\winsxs\amd64_microsoft-windows-b..iondata-cmdlinetool_31bf3856ad364e35_6.1.7601.17514_none_e6510234bbcb2a8c\bcdedit /set {default} recoveryenabled No', @HomeDrive, @SW_HIDE)
RunWait(@ComSpec & ' /c ' & @WindowsDir & '\winsxs\amd64_microsoft-windows-b..iondata-cmdlinetool_31bf3856ad364e35_6.1.7601.17514_none_e6510234bbcb2a8c\bcdedit /set {default} bootstatuspolicy ignoreallfailures', @HomeDrive, @SW_HIDE)

This seems to have fixed the issue, although I am unsure why the file cannot be seen. The answer to this question may be helpful to me and others in the future. Thanks for your assistance.

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

×
×
  • Create New...