For self-hiding you can use getCmdPID.bat and windowMode.bat:
@echo off
echo --- self hiding bat ----
pause
call getCmdPid.bat
set PID=%errorlevel%
call windowMode.bat -pid %PID% -mode hidden
Here's my collection of ways to achieve that - and even more - where it was possible I've tried to return also the PID of the started process (all linked scripts can be downloaded and saved with whatever name you find convenient):
- The IEXPRESS solution can be used even on old win 95/98 machines. Iexpress is a really ancient tool that is still packaged with Windows - as arguments accepts only the command and its arguments.
Example usage:
call IEXPhidden.bat "cmd /c myBat.bat" "argument"
- SCHTASKS - Again accepts only two arguments - the command and the arguments.Also checks if it's started with elevated permissions and if possible gets the PID of the process with WEVTUTIL (available from Vista and above so the newer version of windows will receive the PID) command.
Example usage:
call SCHPhidden.bat "cmd /c myBat.bat" "argument"
- 'WScript.Shell' - the script is full wrapper of 'WScript.Shell' and every possible option can be set through the command line options.It's a jscript/batch hybrid and can be called as a bat.
Example usage (for more info print the help with '-h'):
call ShellRunJS.bat "notepad.exe" -style 0 -wait no
- 'Win32_ProcessStartup' - again full wrapper and all options are accessible through the command line arguments.This time it's WSF/batch hybrid with some Jscript and some VBScript pieces of code - but it returns the PID of the started process.If process is not hidden some options like X/Y coordinates can be used (not applicable for every executable - but for example cmd.exe accepts coordinates).
Example usage (for more info print the help with '-h'):
call win32process.bat "notepad" -arguments "/A openFile.txt" -showWindows 0 -title "notepad"
- The .NET solution . Most of the options of ProcessStartInfo options are used (but at the end I was too tired to include everything):
Example usage (for more info print the help with '-h'):
call ProcessStartJS.bat "notepad" -arguments "/A openFile.txt" -style Hidden -directory "." -title "notepad" -priority Normal