Jump to content

Script not working for UAC


amar3181
 Share

Recommended Posts

I am trying to make a simple exe installation script and Windows UAC pops up. Though I use the send command it doesn't seem to work here.

Run('Test-655.exe')
WinWaitActive("UAC","UAC")
Send("{TAB}")
Send("{TAB}")
Send("{TAB}")
Send("{ENTER}")
WinWaitActive("Dialogpopup","Setup")
 
Is this code correct to send the keyboard command?
Link to comment
Share on other sites

Celtic88, i believe you may be a bit overzealous here. the OP intent may well be legitimate; the thing the OP needs to be aware of is that this forum will not provide any assistance for bypassing security measures.

that said, all the OP needs to do is to acknowledge the UAC - and make the process easier by having the #RequireAdmin directive in his script.

other alternatives - which are better suited for mass deployment - are to use existing deployment services, like the Windows Installer, GPO, remote execution by domain admin, etc.

finally, there are plenty of forum topics about UAC the OP can learn from - although they will not help much when it comes to sporadic installation.

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

Link to comment
Share on other sites

Commands cannot be sent to the UAC prompt from a process ran in user space as the UAC prompt is opened on a separate desktop instance ("Secure Desktop") which cannot be automated from a process started on the normal desktop. This ofcourse is for security purposes.

What you can do is disable the Secure Desktop security, that will probably help (though I have not tested or researched). Lowering the UAC security to bypass the Secure Desktop is only useful if you have to run the script many times on the same machine for testing purposes and don't want to click the UAC every time. But when you run the script on any other machine, you will still have to click through the UAC manually (or manually disable the Secure Desktop on all machines, but that defeats the purpose :) ).

In Windows 7+ you can do this through secpol.msc (if you have windows pro or better). Obviously you would need administrator access for that as well, so it cannot be done from your script (don't waste your time - won't work). See https://support.microsoft.com/kb/975788/en-us for more information.

NOTE: Doing this of course leaves your system highly vulnerable! Take the necessary precautions (backups, restore points, disconnect network, whatever). Ideally, test in a clean virtual machine.

Roses are FF0000, violets are 0000FF... All my base are belong to you.

Link to comment
Share on other sites

Well my question was in general as I am unable to do so with further window. If I just need to have the selected window worked and do not want to worry about specific tittle the is this correct WinWaitActive("")

After that I just need tab pressed 3 times then enter.

Send("{TAB}")

Send("{TAB}")
Send("{TAB}")
Send("{ENTER}")
 
Anything wrong above assumption?
Link to comment
Share on other sites

I made a nice Script that i am lunching with autoit. it disable UAC but you wont be able to run it without typing manualy your credential if that interesting yourself you can message me i will pm you how to do.

My video tutorials : ( In construction )  || My Discord : https://discord.gg/S9AnwHw

How to Ask Help ||  UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote

Spoiler

 Water's UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Link to comment
Share on other sites

I am gonna share my methode since i had some pm's :

With my methode i am using a BAT (batch file) but i launch it with autoit 

YES you will need to use an admin credential manualy. (then reboot after the script usage. only for UAC editing)

1 A:

-make a batch file with that code inside :

:: BatchGotAdmin
:-------------------------------------
REM  --> Check for permissions
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"

REM --> If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (
    echo Requesting administrative privileges...
    goto UACPrompt
) else ( goto gotAdmin )

:UACPrompt
    echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
    set params = %*:"=""
    echo UAC.ShellExecute "cmd.exe", "/c %~s0 %params%", "", "runas", 1 >> "%temp%\getadmin.vbs"

    "%temp%\getadmin.vbs"
    del "%temp%\getadmin.vbs"
    exit /B

:gotAdmin
    pushd "%CD%"
    CD /D "%~dp0"
:--------------------------------------

1 B: 

-Add the code that require admin right below the last line ":----------------------------------------"

For exemple disabling UAC :

C:\Windows\System32\cmd.exe /k %windir%\System32\reg.exe ADD  HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v  EnableLUA /t REG_DWORD /d 0 /f

2 launch the BAT you just made with run in autoit

The BAT file will check if admin right is "ON" or "OFF"

if right is "OFF"  you will be able to enter an admin credential MANUALY

if right is "ON"  the code will be executed without a prompt

This is powerfull if you need to run the autoit script without admin right (for exemple you need to use "@username") and run one specifique thing with admin right like disable UAC...

and yes i was needing that :)

Edited by caramen

My video tutorials : ( In construction )  || My Discord : https://discord.gg/S9AnwHw

How to Ask Help ||  UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote

Spoiler

 Water's UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Link to comment
Share on other sites

Ran both in batch. First code to check admin pops UAC and exits. Second code gives access denied.

You have to do that :

Read: >>>>>>>>>>-Add the code that require admin right below the last line ":----------------------------------------" <<<<<<<<< ;)

:: BatchGotAdmin
:-------------------------------------
REM  --> Check for permissions
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"

REM --> If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (
    echo Requesting administrative privileges...
    goto UACPrompt
) else ( goto gotAdmin )

:UACPrompt
    echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
    set params = %*:"=""
    echo UAC.ShellExecute "cmd.exe", "/c %~s0 %params%", "", "runas", 1 >> "%temp%\getadmin.vbs"

    "%temp%\getadmin.vbs"
    del "%temp%\getadmin.vbs"
    exit /B

:gotAdmin
    pushd "%CD%"
    CD /D "%~dp0"
:--------------------------------------


C:\Windows\System32\cmd.exe /k %windir%\System32\reg.exe ADD  HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v  EnableLUA /t REG_DWORD /d 0 /f

I separated the both code becose you can use the check admin vbs for any other purpose

Edited by caramen

My video tutorials : ( In construction )  || My Discord : https://discord.gg/S9AnwHw

How to Ask Help ||  UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote

Spoiler

 Water's UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Link to comment
Share on other sites

yeah this is what i said, unfortunatly as orbs said we cant help you to bypass that security it s a forum rules but even without that rule i am not sure you can do it.

This script is for disabling UAC Manualy in one click or anything else than UAC

But one thing have to be clear if you got UAC activated you wont be able to automate an admin task.

Edited by caramen

My video tutorials : ( In construction )  || My Discord : https://discord.gg/S9AnwHw

How to Ask Help ||  UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote

Spoiler

 Water's UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Link to comment
Share on other sites

I agree... My  motive wans't bypassing but automating a task. Thanks a lot. Trying another approach hope orbs get it.

If you got a way to do so plz let me know.

My video tutorials : ( In construction )  || My Discord : https://discord.gg/S9AnwHw

How to Ask Help ||  UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote

Spoiler

 Water's UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

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