Whitelist For UAC?

Page 1 of 5 123 ... LastLast

  1. Posts : 526
    Windows 10 (22H2)
       #1

    Whitelist For UAC?


    I recently submitted to living with the UAC prompt for running a certain batch file via shortcut. After some looking around I came across this and request advice, experience and opinions and, if promising, a little help with my script. - thx

    UAC Whitelist for Windows 10 . GitHub
      My Computer


  2. Posts : 5,452
    Windows 11 Home
       #2

    Microsoft security professional volunteers on the forums will tell you how horrible of a idea this is
    Not really, because common users do not use full UAC and those who do, do it already.
    Smart App Control in Windows 11 deals with this problem, basically creating a whitelist.
      My Computer


  3. Posts : 776
    Windows 7
       #3

    This script doesn't create a whitelist, in the normal sense.

    What it does is automate the steps of creating an elevated scheduled task to run your specific command line, and adding a matching shortcut. If you choose to use this PS script, then call the created task from your batch file:

    schtasks run /TN "Name"
    Where "Name" is the task's label in the $whitelist array.

    TenForums has a tutorial, and many posts covering the use of elevated shortcuts to get around the UAC problem.
      My Computer


  4. Posts : 526
    Windows 10 (22H2)
    Thread Starter
       #4

    garlin said:
    ... TenForums has a tutorial, and many posts covering the use of elevated shortcuts to get around the UAC problem.
    It does and I am all too aware of it. However, the forum consensus and much trial and error on my/our part concludes the UAC is still thrown when the 'shortcut' points to a admin-dependant 'batch' file. Thank you all for your input - I was hoping this might solve my UAC suppresion issue, but alas.
      My Computer


  5. Posts : 6,853
    22H2 64 Bit Pro
       #5

    Just an FYI.

    You can create a shortcut to the batch file then run the shortcut elevated when you click on it.

    Whitelist For UAC?-task-scheduler.jpg

    EDIT: To be a little more clear. Here's a shortcut to a batch file. Create the shortcut. Then create an elevated shortcut and place it anywhere you like.

    Whitelist For UAC?-shortcut-batch-file.jpg
    Last edited by Callender; 20 Jul 2023 at 15:46. Reason: remove duplicate attachment
      My Computer


  6. Posts : 526
    Windows 10 (22H2)
    Thread Starter
       #6

    Callender said:
    Just an FYI.

    You can create a shortcut to the batch file then run the shortcut elevated when you click on it.
    yeah, already did that a while back - still throws the UAC. -thx
      My Computer


  7. Posts : 6,853
    22H2 64 Bit Pro
       #7

    Is UAC on max? If so turn it down one notch.
      My Computer


  8. Posts : 6,853
    22H2 64 Bit Pro
       #8

    Or if we can use the batch file post the contents.
      My Computer


  9. Posts : 526
    Windows 10 (22H2)
    Thread Starter
       #9

    Callender said:
    Or if we can use the batch file post the contents.
    taskkill /im Atom.SDK.WindowsService.exe /t /f

    This is one of the services that my vpn uses so, unsure if it helps you much.
      My Computer


  10. Posts : 776
    Windows 7
       #10

    The posted PS script can be reworked to exclusively run batch files, and create a normal desktop shortcut.
    Code:
    $whitelist = @{
        "Script 1" = "C:\Users\GARLIN\batch.cmd"
        "Script 2" = "C:\Users\GARLIN\other_batch.cmd"
    }
    
    $tasksPath = "\UAC Whitelist"
    $shortcutsDir = "$env:USERPROFILE\Desktop"
    
    $user = [System.Security.Principal.WindowsIdentity]::GetCurrent().Name
    $principal = New-ScheduledTaskPrincipal -UserId $user -LogonType Interactive -RunLevel Highest
    
    $whitelist.GetEnumerator() | ForEach-Object {
        $name = $_.Name
        $file = $_.Value
    
        # Create "scheduled" task
        $action = New-ScheduledTaskAction -Execute "C:\Windows\System32\cmd.exe" -Argument ('/c ' + $file)
        $task = New-ScheduledTask -Action $action -Principal $principal
        Register-ScheduledTask -Force -InputObject $task -TaskPath $tasksPath -TaskName $name
    
        # Create shortcut to run the above task
        $WshShell = New-Object -ComObject WScript.Shell
        $shortcut = $WshShell.CreateShortcut("$($shortcutsDir)\$($name).lnk")
        $shortcut.TargetPath = "C:\Windows\System32\schtasks.exe"
        $shortcut.Arguments = "/RUN /TN `"$($tasksPath)\$($name)`""
        $shortcut.IconLocation = "C:\Windows\System32\cmd.exe,0"
        $shortcut.WorkingDirectory = "C:\Windows\System32"
        $shortcut.Save()
    }
    batch.cmd
    Code:
    COPY NUL C:\TEST.txt

    The shortcut now runs your file with Admin rights. Or you can call the scheduled task from inside another batch file.
    Code:
    C:\Users\GARLIN>batch.cmd
    
    C:\Users\GARLIN>COPY NUL C:\TEST.txt
    Access is denied.
            0 file(s) copied.
    
    C:\Users\GARLIN>schtasks /run /tn "\UAC Whitelist\Script 1"
    SUCCESS: Attempted to run the scheduled task "\UAC Whitelist\Script 1".
    
    C:\Users\GARLIN>dir C:\
     Volume in drive C has no label.
     Volume Serial Number is 16C2-2E4E
    
     Directory of C:\
    
    05/06/2022  10:24 PM    <DIR>          PerfLogs
    07/17/2023  05:44 PM    <DIR>          Program Files
    07/15/2023  02:27 PM    <DIR>          Program Files (x86)
    07/20/2023  02:02 PM                 0 TEST.txt
    07/17/2023  09:48 PM    <DIR>          Users
    07/16/2023  01:03 AM    <DIR>          Windows
                   1 File(s)              0 bytes
                   5 Dir(s)  26,620,268,544 bytes free
    Last edited by garlin; 20 Jul 2023 at 16:32.
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 00:34.
Find Us




Windows 10 Forums