Last active
December 3, 2024 02:29
-
-
Save Ultraporing/914655685252e1d7320f308902369771 to your computer and use it in GitHub Desktop.
Run Powershell Script in the same file with doubleclick Snippet. $ScriptHome is set as replacement for $PSScriptRoot since its unset. Put this snippet in the beginning of your .cmd file. Thanks to "kapitanrum" and "Tydaeus" on stackoverflow for the awesome snippet and explanation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# : batch script | |
@echo off | |
setlocal | |
cd %~dp0 | |
start pwsh -executionpolicy remotesigned -NoExit -Command "Invoke-Expression $($ScriptHome = '%~dp0'; [System.IO.File]::ReadAllText('%~dpf0'))" | |
endlocal | |
goto:eof | |
#> | |
# here write your powershell commands... | |
# optionally set the window title | |
$host.ui.RawUI.WindowTitle = "My Powershell Script" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment