Sign in to follow this  
Followers 0
JoshuaBarnette

#RequireAdmin Not Elevating Sub-Processes

4 posts in this topic

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

Share this post


Link to post
Share on other sites



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

 


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Are you running the 64-bit edition of Windows 7 ? If so, you need to compile your script(s) using x64, due to Windows' file & registry redirection when running a 32-bit executable process on a 64-bit OS.

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

  • Similar Content

    • steveeye
      By steveeye
      hey, can anybody enlighten on lesser known Windows hacks or uses ?
    • tcurran
      By tcurran
      Here's a short UDF that will, at least in most cases, detect whether a window can be copied from or pasted to programmatically--for example, by Send()ing ctl-c, ctl-v. This is often disabled when programs (like your AutoIt script) run at a lower UAC integrity level than the application they are trying to operate on.
      #include <WinAPI.au3> Func _WindowIsPasteable($handle) ;accepts window handle; returns true or false whether a window will accept Ctl-C, Ctl-V Local $bCanPaste = True Local $hTestWindowPID = 0 Local $hTestWindowTID = _WinAPI_GetWindowThreadProcessId($handle, $hTestWindowPID) _WinAPI_AttachThreadInput(_WinAPI_GetCurrentThreadId(), $hTestWindowTID, True);attach to window we want to paste into $bCanPaste = _WinAPI_GetFocus() ;Test whether window is paste-able--returns False if it is not _WinAPI_AttachThreadInput(_WinAPI_GetCurrentThreadId, $hTestWindowTID, False);detach from window thread Return $bCanPaste EndFunc Pass it a window handle; it returns true or false whether a window will accept programmatic pasting. The function may not work on the CMD window, since it handles the clipboard uniquely.
      This function works by attaching to the program thread of the window whose handle it receives, then attempting to perform a GetFocus on that thread. In most cases, the attempt will fail if the window will not accept programmatic copy-paste.
    • afallenhope
      By afallenhope
      Hello all! 
      I am having a bit of trouble and was wondering if anyone may have a workaround for my issue. I made a script that would automatically install a piece of software each night on a Windows 7 Box. Now I have been instructed to do the same with a Windows 10 box since the application is now being tested on Windows 10. 
      The way I did the win7 installation was that I made a script and then made an executable that I call with a batch file along with the Installer. So the process is 
      AutoitMainFile calls batch file, batch file opens Installer, and the automatedinstaller.exe  The automatedinstlaller waits 10-20 seconds to make sure the Installer has been fully loaded.
      When I try to do the same both get loaded but the automatedinstallation.exe does not send commands to the installer. The code does work and nothing from the program we are wanting to install has changed as our Windows 7 runs every night no problem. 
       
      Do I need to make a new automatedinstall script for windows 10? 
      Any advice is appreciated 
      Thanks,
      Richard
    • dreivilo47
      By dreivilo47
      When I use the following code I receive an UAC message:
       
      #RequireAdmin RunWait("msiexec /i winzip205-64.msi /quiet") Exit How can I hide (bypass) the UAC message?
    • ur
      By ur
      I have enabled admin sharing in the remote machine so that I can copy files to the remote machine use PSEXEC to execute our application remotely.
        Now, if the machine is poweredoff we need to poweriton. So I checked whether the remote machine, it is of both VirtualBox or VMWare one. For VirtualBox or VMware, I have found command line utities to poweron.   But to autologon by skipping the login screen.Can anyone suggest how to do the same.If it is a physical machine, then there is no need to poweron but autologon is required.   I am trying for windows machines.Win 7 at present.   For VirtualBox I checked below link with help og guestadditions but not working. http://www.virtualbox.org/manual/ch09.html#autologon   The below procedure will save the password in that machine and it will logon automatically.   http://www.howtogeek.com/112919/how-to-make-your-windows-8-computer-logon-automatically/   But it will give access to everyne.But my opinion is he should access only if have credentias.I mean through any commandline from another machine he should trigger logon also by passing credentials.     Similarly this also   http://www.cnet.com/how-to/automatically-log-in-to-your-windows-10-pc/   http://superuser.com/questions/28647/how-do-i-enable-automatic-logon-in-windows-7-when-im-on-a-domain   http://pcsupport.about.com/od/windows7/ht/auto-logon-windows-7.htm   http://www.computerperformance.co.uk/windows7/windows7_auto_logon.htm   https://technet.microsoft.com/en-us/magazine/ee872306.aspx   Please guide me how to proceed.