Closed Tuphal closed 2 months ago
Hi! Running a program in the background from a batch file in Windows requires combining batch scripting with VBScript, as there is no direct way to hide the command prompt window using only batch commands.
You can achieve this by creating a temporary VBScript that runs your application and then hides the command prompt window. Here’s how you can do it:
@echo off
set appPath="C:\Users\Administrator\AppData\Local\Programs\nightscout-widget-electron\Owlet.exe"
set vbsScript="%temp%\invisible.vbs"
echo Set WshShell = CreateObject("WScript.Shell") > %vbsScript%
echo WshShell.Run %appPath%, 0 >> %vbsScript%
cscript //nologo %vbsScript%
del %vbsScript%
In this script:
@echo off
prevents the commands from being displayed in the command prompt.set appPath
sets the path to your application.set vbsScript
creates a temporary VBScript file in the system’s temporary directory.echo
commands create the VBScript that runs the application in the background.cscript //nologo %vbsScript%
runs the VBScript without showing the Windows Script Host logo.del %vbsScript%
deletes the temporary VBScript file after it has been executed.Alternatively, you can use a VBScript or PowerShell script to achieve similar results. Batch scripting creates a synchronous process tied to the command window, which is why this additional scripting is necessary to hide the command prompt window.
Contact Details
No response
What happened?
I'm using a batch file to start all programs after boot. As soon as the cmd-line windows is closed, Owlet is also closed.
Same happens, when I open Owlet.exe directly with cmd-line with the same start-cmd as from the batch file:
start "" "C:/Apps/Owlet_Nightscout/Owlet.exe"
When opening the Owlet.exe by hand, it stays open. Is there any argument/parameter to pass, so that Owlet will stay open?
Steps to reproduce?
start "" "C:/Apps/Owlet_Nightscout/Owlet.exe"
Screenshot?
No response
Application version
0.8.2-beta (Latest)
What operating system are you seeing the problem on?
MS Windows
Operating system's version and architecture
Win 10 Pro 22H2 and Enterprise 22H2
Relevant log output or debug info
No response