Skip to content

Instantly share code, notes, and snippets.

View MajorTomAW's full-sized avatar

MajorT MajorTomAW

  • Germany
  • 19:27 (UTC -12:00)
View GitHub Profile
@jamiephan
jamiephan / Hidden.bat
Last active October 14, 2024 14:19
Launch a batch file without showing the window, within one file and without third-party tools
@echo off
if not "%1"=="Opened_Via_PS" (
pushd %~dp0
REM //TODO: Use Env variable instead of passing checking arg.
rem Adopted from https://superuser.com/questions/62525/run-a-batch-file-in-a-completely-hidden-way
rem The " ^" at the end is similar to " \" for multi-line scripts.
rem Extend the %1 %2 (%3...) below if you have multiple command line args.
powershell.exe -NoLogo -NoProfile -WindowStyle Hidden -NonInteractive -ExecutionPolicy Bypass -Command ^
"(New-Object -ComObject WScript.Shell).Run('\"%cd%\%~n0%~x0\" Opened_Via_PS %1 %2', 0, 'false')"