1

I currently have a .cmd file that runs the following two commands on startup

PowerShell -Command "Set-ExecutionPolicy Unrestricted" >> "%TEMP%\StartupLog.txt" 2>&1
PowerShell C:\Users\elias\Desktop\Script123.ps1 >> "%TEMP%\StartupLog.txt" 2>&1

But when this runs on startup it shows the command prompt. I'm wondering if there's anyway to run this without showing the command prompt.

Thank You

Elias RC
  • 69
  • 2
  • 6

3 Answers3

0

Invoking a .cmd file directly invariably opens a console window, so you need to invoke it via a wrapper executable that hides it:

This answer of mine contains a VBScript script that does just that; assuming you've saved it as runHidden.vbs in the current dir and that you want to invoke some-batch-file.cmd from the current dir:

wscript .\runHidden.vbs cmd "/c .\some-batch-file.cmd"
mklement0
  • 382,024
  • 64
  • 607
  • 775
0

Try powershell -command "& { $x = New-Object -ComObject Shell.Application; $x.minimizeall() }" in the beginning of the code.

This command can minimize all windows.

I hope this can be helpful, if you have any other questions, please comment below.

Benjamin2002
  • 311
  • 1
  • 4
  • 13
0

Create a wrapper with VBScript:

Option Explicit
Dim WshShell
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run "cmd /c blah.cmd", 0, False

Then change the startup item to

wscript.exe wrapper.vbs
iBug
  • 35,554
  • 7
  • 89
  • 134