memstechtips / UnattendedWinstall

Personalized Unattended Answer Files that helps automatically debloat and customize Windows 10 & 11 during the installation process.
MIT License
2.79k stars 338 forks source link

Run PowerShell as Admin #30

Closed SCHEFFRA closed 2 months ago

SCHEFFRA commented 3 months ago

Seems that the Powershell script "LAUNCH-CTT-WINUTIL.ps1" has to be executed with admin permission, so it would be helpfull to integrate also the right click option like "run with powershell (admin)"

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\Run with PowerShell (Admin)] [HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\Run with PowerShell (Admin)\Command] @="\"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe\" \"-Command\" \"\"& {Start-Process PowerShell.exe -ArgumentList '-ExecutionPolicy RemoteSigned -File \\"%1\\"' -Verb RunAs}\""

memstechtips commented 3 months ago

Thank you so much for this! Now I don't have to go and search for it.

Will test it out in the development branch and add to main if it works.

ViwuAndYouKnow commented 3 months ago

I have created a different method using cmd, took me some time to get it working, it gives an error when ran but it will still launch the software without the need of looking for powershell at all. Enjoy :)

"# Creates Desktop Shortcut for the Chris Titus Windows Utility So You Can Easily Launch it to Install Programs $path = "C:\Users\Default\Desktop\Launch-CTT-WinUtil.bat" $content = '@echo off & net session >nul 2>&1 || powershell -Command "Start-Process \"cmd.exe\" -ArgumentList \"/c %~f0\" -Verb RunAs" && exit /B & powershell.exe -Command "iex (iwr \"https://www.christitus.com/win\")"'

Update: found a fix for the error and boon issue, pull request created.

Spomsoree commented 2 months ago

A text file with a short how to, on how to run iwr -useb https://christitus.com/win | iex would be cool too.

memstechtips commented 2 months ago

Thanks for all the contributions and ideas, it's now fixed in https://github.com/memstechtips/UnattendedWinstall/commit/a9348a19ad425bb840c2a3e4e67501a81715ef66