"Run as TrustedInstaller" from Context menu

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

  1. retest

    retest MDL Member

    Nov 2, 2010
    115
    63
    10
    I use this in my AutoIt script and it works fine :
    Code:
        RegWrite('HKCR\batfile\shell\' & $MenuLabel1 & '\shell\35'& $MenuLabel1,    '',            'REG_SZ', $MenuText)
        RegWrite('HKCR\batfile\shell\' & $MenuLabel1 & '\shell\35'& $MenuLabel1,    'MUIVerb',    'REG_SZ', $MenuText)
        RegWrite('HKCR\batfile\shell\' & $MenuLabel1 & '\shell\35'& $MenuLabel1,      'Icon',        'REG_SZ', '"' & $sInstExePath & '", 0')
        RegWrite('HKCR\batfile\shell\' & $MenuLabel1 & '\shell\35'& $MenuLabel1 & '\command',    '',            'REG_SZ', '"' & $sInstExePath & '" "/WD:%W" "%L"')
    
    I previously had /WD:"folderpath" and that worked OK too.
    Since the developer has specified to include the /WD: within quotes that's what I do now.

    This is a bat file generated by PowerRun :
    Code:
    @Echo Off
    Start "" "D:\PowerRun Portable\PowerRun_x64.exe" "/WD:%SystemDrive%\Portable Programs\Notepad2\" "%SystemDrive%\Portable Programs\Notepad2\Notepad2.exe"
    pause
    
     
  2. monstrocity

    monstrocity MDL Novice

    Jun 4, 2016
    48
    24
    0
    #82 monstrocity, May 18, 2024
    Last edited: May 18, 2024
    Code:
    reg add "HKCR\*\shell\Run as TrustedInstaller" /v "Icon" /t REG_SZ /d "imageres.dll,208" /f >NUL
    If anyone is running W11 Enterprise (iot) LTSC 24H2 and uses this bat script from the OP, you'll need to change the icon ID from 101 to 208 for the correct icon to show. Otherwise, you may see a green check mark instead. Not a big deal other than cosmetics.
     
  3. freddie-o

    freddie-o MDL Expert

    Jul 29, 2009
    1,536
    2,545
    60
    "imageres.dll,101" shows a green shield with a checkmark icon for both Windows 10 and 11
    "imageres.dll,208" in Windows 11 is "imageres.dll,1" in Windows 10
    But it's up to you guys what icon you prefer to use
     
  4. Acideb135

    Acideb135 MDL Junior Member

    Jun 25, 2024
    61
    16
    0
    Thanks , and on your post #1 https://forums.mydigitallife.net/threads/run-as-trustedinstaller-from-context-menu.80713/ we can see on the spoiler in your context menu "Fast delete" , "Unlock and delete" and "kill explorer unlock and delete"
    Can you post another thread for this or explanations. There is interesting, thanks

    I found for fast delete a very good multithreaded folder removal app But i I can't launch it from the context menu because I think i am missing the path of the file when I right click on it, but how to integrate it.
     
  5. freddie-o

    freddie-o MDL Expert

    Jul 29, 2009
    1,536
    2,545
    60

    I rarely use these functions so I don't think it merits a new Thread
    They also don't work 100% of the time
    Fast Delete bypasses the Recycle bin so you cannot restore deleted files anymore so you have to use it with caution


    I use 3rd party apps and their corresponding command lines for these

    FastCopy has a very powerful delete function
    LockHunter for unlocking files
    PowerRun for TrustedInstaller privileges




    I'm not familiar with this App
    I use the Registry to add processes to the Context menu
     
  6. retest

    retest MDL Member

    Nov 2, 2010
    115
    63
    10
    There's a new version of PowerRun. v1.7

    File -> Allow command line.

    This might impact your script. Maybe.

    Capture_2024-07-18_073756.jpg
     
  7. freddie-o

    freddie-o MDL Expert

    Jul 29, 2009
    1,536
    2,545
    60
    #87 freddie-o, Jul 18, 2024
    Last edited: Jul 18, 2024
    (OP)
    Thanks it does.
    I use the Reg file to add "Run as TrustedInstaller" to the Context Menu. I can manually "Allow Command Line" so it doesn't affect me
    I don't know how to automate this using the Batch script
    @inTerActionVRI do you?
    Or do we now have to manually download PowerRun, "Allow Command Line" then run the Bat script?
     
  8. inTerActionVRI

    inTerActionVRI MDL Expert

    Sep 23, 2009
    1,725
    3,520
    60
    What is the System version of your machine?
    Go to search, type winver and open it to obtain this data.
    Ex: 22631.xxxx x64


    This is something new. I have this done for the restriction via PowerShell scripts. I need to have time to see this. I will see. Maybe when I see someone I might have discovered something.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  9. retest

    retest MDL Member

    Nov 2, 2010
    115
    63
    10
    Nothing to do with Windows version.

    PowerRun has been updated and has a new feature/option.

    PowerRun v1.7 cannot be run from command line unless you first run the GUI and click File -> Allow command line..

    A entry is made in the INI file (SecurityCode=xxxxxxxxxx).
     
  10. raptorddd

    raptorddd MDL Addicted

    Aug 17, 2019
    721
    271
    30
    #90 raptorddd, Jul 25, 2024
    Last edited: Jul 25, 2024
    yesterday i faced this too. when right clikc to runs as trust installer i get
    Screenshot 2024-07-25 130527.png

    i already downloaded powerrun v 1.7
    clicked allow coomand line now it has a checkmark and its greyed out. but i still cant run script. still shows you must select allow commnad line

    any other way to runs as trust installer.? i clean installed and need to run some scripts but this was the only way i knew on how to run as trsust installer if theres is a way with video would be cool. or a way to continue this way on this thread.
    thank you
     
  11. redsunset

    redsunset MDL Member

    Mar 16, 2022
    143
    60
    10
    Have you tried running pwsh/cmd from powerrun itself, cd to your script location and run it by using .\ as in .\script.cmd ?

    happens here also
    [​IMG]
     
  12. freddie-o

    freddie-o MDL Expert

    Jul 29, 2009
    1,536
    2,545
    60

    The script just copies PowerRun.exe to System32 folder not including the INI file
     
  13. redsunset

    redsunset MDL Member

    Mar 16, 2022
    143
    60
    10
    in my case, there's was a powerrun.ini file in System32 also, so I replaced it with the one from og powerrun folder and now it works properly
     
  14. retest

    retest MDL Member

    Nov 2, 2010
    115
    63
    10
    Just a suggestion :
    - use a bat file instead of reg file.
    - instruct user to copy the bat file to the same directory as PRun.
    - bat file will now have the address of PRun exe.
    - user will not have to edit a reg file (what with the double backslashes and all ;-)
    - add a context menu entry only for
    batfile
    cmdfile
    cplfile ?
    exefile
    mscfile ?

    - try superUser instead of PRun, many of us prefer it to PRun.
    https://github.com/mspaintmsi/superUser

    EDIT : the bat file can check if PRun exists in the same folder.
    and (maybe) check if the INI file has at least one value for Securitycode.
     
  15. Patch0

    Patch0 MDL Novice

    Jan 30, 2013
    7
    1
    0
  16. freddie-o

    freddie-o MDL Expert

    Jul 29, 2009
    1,536
    2,545
    60
  17. inTerActionVRI

    inTerActionVRI MDL Expert

    Sep 23, 2009
    1,725
    3,520
    60
    The only way I found to make this work properly was to put a message before launching the PowerRun window, asking the user to grant permission.
    And after that, start copying the files with the ini already changed, with the permission of your machine, in the system32 folder.
    In this way works well.

    upload_2024-7-27_15-17-18.png

    If the code is the same at this point, for any machine, I believe this is temporary.
    My code starts with E9xxxxxxxx
     

    Attached Files:

    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...