"Run as TrustedInstaller" from Context menu

Discussion in 'Scripting' started by freddie-o, Dec 3, 2019.

  1. Owned67

    Owned67 MDL Novice

    Dec 9, 2009
    10
    2
    0
    #61 Owned67, Jan 4, 2024
    Last edited: Jan 4, 2024
    Thanks very much, will try and give a feedback.

    Edit 01/04/2024: nothing work for me...

    tested .bat file => all good no error, logout and restarted but same as before, it's launched as a single user...

    tested .reg file and same result.

    UAC is completly OFF


    re edit at 13h14 pm:

    I've try to add this on batch file:
    Code:
    @echo off
    setlocal
    
    
    :checkPrivileges
    NET FILE 1>NUL 2>NUL
    if '%errorlevel%' == '0' ( goto gotPrivileges ) else ( goto getPrivileges )
    :getPrivileges
    if '%1'=='ELEV' (echo ELEV & shift /1 & goto gotPrivileges)
    echo NO
    pause
    
    :gotPrivileges
    if '%1'=='ELEV' shift /1
    setlocal & pushd .
    cd /d %~dp0
    echo YES
    pause
    and seems good, it return YES everytime. Just i don't have Administrator when cmd is opened, weird... Thanks very much for help!
     
  2. freddie-o

    freddie-o MDL Expert

    Jul 29, 2009
    1,571
    2,615
    60
    I modified the scripts to delete the keys first then re-apply them. See if this works
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. Owned67

    Owned67 MDL Novice

    Dec 9, 2009
    10
    2
    0
    with the update, all working correctly, thanks very much
     
  4. W7W10

    W7W10 MDL Novice

    May 11, 2023
    44
    4
    0
    #64 W7W10, May 12, 2024
    Last edited: May 13, 2024
    The mistake I'm sorry.
     
  5. freddie-o

    freddie-o MDL Expert

    Jul 29, 2009
    1,571
    2,615
    60
    The scripts in the OP are final and tested
    Did you mean the ready-made scripts?
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  6. W7W10

    W7W10 MDL Novice

    May 11, 2023
    44
    4
    0
    #66 W7W10, May 13, 2024
    Last edited: May 13, 2024
    The mistake I'm sorry.
     
  7. freddie-o

    freddie-o MDL Expert

    Jul 29, 2009
    1,571
    2,615
    60
    OP = original poster or original post
    It's good to know some basics on creating batch scripts or reg files
    Like with the script posted in the OP...
    You just need to copy/paste it to a text editor like, I use, Notepad++ then save as batch (*.bat, *.cmd) file or registry (*.reg) file
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  8. W7W10

    W7W10 MDL Novice

    May 11, 2023
    44
    4
    0
    #68 W7W10, May 13, 2024
    Last edited: May 13, 2024
    Thank you very much for this.
     
  9. freddie-o

    freddie-o MDL Expert

    Jul 29, 2009
    1,571
    2,615
    60
    The reason I use PowerRun is after trying a lot of TI apps/scripts, I haven't run into any errors "yet". It's still the most reliable one
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  10. retest

    retest MDL Member

    Nov 2, 2010
    116
    63
    10
    what is the /R parameter for?
    Code:
    "cmd.exe /X /D /U /R 
     
  11. freddie-o

    freddie-o MDL Expert

    Jul 29, 2009
    1,571
    2,615
    60
    #71 freddie-o, May 15, 2024
    Last edited: May 15, 2024
    (OP)
    accidentally created a new post. see next post
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  12. freddie-o

    freddie-o MDL Expert

    Jul 29, 2009
    1,571
    2,615
    60
    Not sure maybe @inTerActionVRI can enlighten us
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  13. retest

    retest MDL Member

    Nov 2, 2010
    116
    63
    10
    ya, i tried searching. not mentioned anywhere else.
     
  14. Carlos Detweiller

    Carlos Detweiller Emperor of Ice-Cream

    Dec 21, 2012
    6,786
    7,748
    210
    According to cmd.exe help, /R is a historical alias for /C - "Carries out the command specified by string and then terminates".
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  15. retest

    retest MDL Member

    Nov 2, 2010
    116
    63
    10
    I think
    Code:
    PowerRun.exe /WD:\"%%%%~dp#\"
    is slightly wrong. The PowerRun help says even the /WD: should be within the double quotes.like "/WD:folderpath".

    Check a bat file generated by PowerRun.
     
  16. freddie-o

    freddie-o MDL Expert

    Jul 29, 2009
    1,571
    2,615
    60
    There is no hard-and-fast rule in coding. There are different variations to scripting. What's important is it works and gets the job done
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  17. freddie-o

    freddie-o MDL Expert

    Jul 29, 2009
    1,571
    2,615
    60
    I updated the scripts in the OP to show the correct icon on both Windows 10 and 11.
    The icon numbering of imageres.dll in Windows 10 and 11 are different.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  18. acer-5100

    acer-5100 MDL Guru

    Dec 8, 2018
    4,003
    2,924
    150
    Just a little nitpick.
    To avoid having the same icon for run as administrator/run as powerrun I suggest using something else than user32dll,6

    Not that I browsed all the icons available but something like
    shdocvw.dll,0 (exclamation mark on yellow shield) would do the job
     
  19. freddie-o

    freddie-o MDL Expert

    Jul 29, 2009
    1,571
    2,615
    60
    Thanks, I didn't see that
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  20. inTerActionVRI

    inTerActionVRI MDL Expert

    Sep 23, 2009
    1,748
    3,575
    60
    change it from:
    Code:
    /WD:\"%%%%~dp#\"
    
    to:
    Code:
    \"/WD:%%%%~dp#\"
    
    Do the test, and bring to US the result.