Create Elevated Shortcut without UAC prompt in Windows 10  

Page 15 of 20 FirstFirst ... 51314151617 ... LastLast

  1. Posts : 5
    Windows 10
       #140

    Thanks for the very speedy response. I didn't realize there were so many options. Clicking on a file does work already with the security warning window. But that is a major hassle if you are editing dozens of files in rapid succession. I'll look through all of the options you mentioned where maybe some hack might work.
      My Computer

  2. Matthew Wai's Avatar
    Posts : 5,150
    Windows 10 Home 20H2
       #141

    Option one works with a CMD script file. It is possible to run your WAV file via a CMD file and create an elevated shortcut to the CMD file.
      My Computer


  3. Posts : 5
    Windows 10
       #142

    This is pretty interesting. I spent quite a bit of time debugging my own batch file that creates a scheduled task. There are lots of hurdles. But in the end my account didn't have permissions to actually run the scheduled task (in super user mode) and I couldn't get an argument to the command to execute to work. I last figured that creating an XML file to give all of the information might help.

    Then I tried your script Matthew and that got around the permissions issue. I not sure if the reason is that you did some things with PowerShell or if the XML input was the key.

    So the next step is to pass a file name argument somehow. My result looks different from yours in that my XML information uses the <Arguments>command</Arguments> layout while yours uses <Command>command</Command>

    Maybe it would be possible to enter the filename in the <Arguments> form instead.

    schtasks /QUERY /XML | findstr My
    <!-- \MyTask -->
    <URI>\MyTask</URI>
    <Arguments>/c start "MyTask" "\Program Files (x86)\MyTask.exe"</Arguments>
    <!-- \Apps\MyTask -->
    <URI>\Apps\My_Task</URI>
    <Command>"C:\Program Files (x86)\MyTask"</Command>
      My Computer

  4. Matthew Wai's Avatar
    Posts : 5,150
    Windows 10 Home 20H2
       #143

    Aeolian said:
    Then I tried your script Matthew and that got around the permissions issue. I not sure if the reason is that you did some things with PowerShell or if the XML input was the key.
    PowerShell enables the script to import the XML file with administrative privileges. The task will be run with highest privileges.

    Aeolian said:
    <Command>"C:\Program Files (x86)\MyTask"</Command>
    The <Command> does not work without the extension .exe
    You should have entered C:\Program Files (x86)\MyTask.exe as the file path.
    <Arguments> is not necessary. You may delete the task and try again.
      My Computer


  5. Posts : 5
    Windows 10
       #144

    Okay, then I think I'll use your script to create the base scheduled task (without an argument). Then I'll create a much simpler one that will get triggered through the file type handling system that will pass in the file name. That simpler script will add the file name in the argument field and fire the task using

    schtasks /change /tn MyTask /tr MyCommand FILENAME
    schtasks /run /tn MyTask

    It should work I believe. If so, there'll be no need to call a second batch file. The application will be run directly.

    P.S. As you surely know, the XML interface is needed to set some things that are otherwise kind of broken - such as not shutting down your process (thereby losing all of your changes) when the laptop suddenly switches to battery power or goes idle :)
    Last edited by Aeolian; 31 May 2020 at 14:19.
      My Computer

  6. Matthew Wai's Avatar
    Posts : 5,150
    Windows 10 Home 20H2
       #145

    Aeolian said:
    Okay, then I think I'll use your script to create the base scheduled task (without an argument).
    Check whether an argument is needed simply by running the following via an elevated Command Prompt:

    "C:\Program Files (x86)\MyTask.exe"

    If "MyTask.exe" is run, just enter C:\Program Files (x86)\MyTask.exe (without quotation marks) into my script.

    Aeolian said:
    P.S. As you surely know, the XML interface is needed to set some things that are otherwise kind of broken - such as not shutting down your process (thereby losing all of your changes) when the laptop suddenly switches to battery power or goes idle :)
    My script uses the following conditions, which should serve your needs:

    Create Elevated Shortcut without UAC prompt in Windows 10-task-conditions.jpg
      My Computer


  7. Posts : 5
    Windows 10
       #146

    The argument is quite necessary to make it work. Remember that I need to double click on files in the directory browser. Fortunately I succeeded in doing the above. Unfortunately the combination of a command in a directory that includes spaces plus an audio file in a directory that includes spaces is not working. Either alone works fine. I guess it's just a matter of adding the right path delimiter characters. Or maybe it is easiest to move the application out of the accursed "Program Files (x86)" directory.
      My Computer

  8. Matthew Wai's Avatar
    Posts : 5,150
    Windows 10 Home 20H2
       #147

    Can you post the full paths, commands, and arguments?
      My Computer


  9. Posts : 17
    W10 W8.1 W7
       #148

    Hi to all, hi Shawn,

    below please find the .bat I want to call from a desktop shortcut from a nonAdmin account without UAC prompt.

    I tried to run it with "C:\Windows\System32\runas.exe /noprofile /user:adm /savecred". But this only seems to work for .exe Files.

    Code:
    @echo off
    set "newE=daten*"
    set "newD=extSSD*"
    mountvol d: /D
    mountvol e: /D
    for /f "tokens=2,3 delims= " %%A in ('echo list volume ^| diskpart ^| findstr "%newD%"') do (
    set drvD=%%B
    (echo select volume %%A
    echo assign letter=D) | diskpart >nul
    )
    set "lettE=E"
    if /I [%drvD%] EQU [] (set "lettE=D" & echo. & echo !!!!!!!!!!!!!!!!!!! %newD% not found !!!!!!!!!!!!!!!!!!!)
    for /f "tokens=2,3 delims= " %%A in ('echo list volume ^| diskpart ^| findstr "%newE%"') do (
    (echo select volume %%A
    echo assign letter=%lettE%) | diskpart >nul
    )
    echo list volume | diskpart
    pause
    I saw the way with the schedtasks, but dislike the idea that every .bat will have its own sched task.

    1 Is there a way to make runas also work for .bat ? (would be my choice then)

    2 I read about some other ways in 7/8forums. Which one will work for W10pro without installing any additional tools ?

    3 Is there a way just to have one sched task handling all the .bat it gets from the call of a desktop shortcut ?
      My Computer

  10. Brink's Avatar
    Posts : 56,483
    64-bit Windows 10 Pro for Workstations build 21364
    Thread Starter
       #149

    Hello @5ggggg,

    To have a .bat file always "Run as administrator", you could do this below. You will get a UAC prompt though.

    1) Keep the .bat file saved where you want on the computer.

    2) Create a shortcut of the .bat file, put the shortcut where you want to use it at.

    3) Use option 9 here to set the shortcut to always "Run as administrator".
      My Computers


 
Page 15 of 20 FirstFirst ... 51314151617 ... LastLast

Tutorial Categories

Create Elevated Shortcut without UAC prompt in Windows 10 Tutorial Index Network & Sharing Instalation and Upgrade Browsers and Email General Tips Gaming Customization Apps and Features Virtualization BSOD System Security User Accounts Hardware and Drivers Updates and Activation Backup and Restore Performance and Maintenance Mixed Reality Phone


  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 03:24.
Find Us




Windows 10 Forums