Adding my answer here from another post since it was a duplicate and I don't see this solution here so now there are 17 different answers
for how you can run a batch file hidden. I will delete my answer on that post at some point in the near future.
Create your batch script with your batch logic and commands in it, and then create a new file with .VBS
extension, use the below logic (example I provided below) and just plug in the full path to your .CMD
or .BAT
file with the PING -t <IPAddress>
, etc. commands so it executes the batch in a hidden manner not showing the command window when it is executed.
Where the logic in the example below specifies C:\Folder\BatchFileName.cmd
change that to point to the batch script with your commands you are running manually, etc. now.
Save the .VBS
file and schedule it with Task Scheduler
Problems scheduling a task on windows7 to run on an indefinite schedule for your needs.
Otherwise, just double-click on the .VBS
file to run the infinite PING
command you put in the batch file you point it to as-needed.
NOTE: I believe this is where I got this script logic from but it works reliably for the same purpose you need here which is to ensure the command window is hidden when a batch file is run Server Fault Source
EXAMPLE VBS SCRIPT RUN COMMAND LINE BATCH HIDING CMD WINDOW
Set WinScriptHost = CreateObject("WScript.Shell")
WinScriptHost.Run Chr(34) & "C:\Folder\BatchFileName.cmd" & Chr(34), 0
Set WinScriptHost = Nothing
EXAMPLE 2
Note: This looks for a bat file with the same name. You can change bat to cmd in script, if needed with this example.
If WScript.Arguments.Count <= 0 Then
WScript.Quit
End If
bat = Left(WScript.ScriptFullName, InStrRev(WScript.ScriptFullName, "\")) & WScript.Arguments(0) & ".bat"
arg = ""
If WScript.Arguments.Count > 1 Then
arg = WScript.Arguments(1)
End If
CreateObject("WScript.Shell").Run """" & bat & """ """ & arg & """", 0, False