[英]How do I run a windows task without flashing a command prompt box BUT still show a dialog box when I need to?
I creating a scheduled task in windows using windows command prompt: 我使用Windows命令提示符在Windows中创建计划任务:
schtasks /create /sc minute /mo 30 /tn "javadobe" /tr "\Program Files (x86)\BuildingIntelligence\javadobe\node.exe '\Program Files (x86)\BuildingIntelligence\javadobe\index.js'" /RL HIGHEST
Which is telling the command line to run "node index.js" every 30 minutes with the highest running privileges. 这是告诉命令行以最高的运行特权每30分钟运行一次“ node index.js”。
In my index.js file, I am checking a remote server for a version number I compare against a local version number. 在我的index.js文件中,我正在检查远程服务器上与本地版本号进行比较的版本号。 Now when they are the same, a node prompt window flashes briefly on the screen, which is obnoxious, and I would like to stop. 现在,当它们相同时,节点提示窗口在屏幕上短暂闪烁,这很令人讨厌,我想停下来。 However, when the host server uploads a new version of the software, I show a dialog box asking the user if they want to install the update now or later. 但是,当主机服务器上载软件的新版本时,我显示一个对话框,询问用户是否要立即或稍后安装更新。 I want to keep this functionality. 我想保留此功能。
How can I keep the dialog box popping up but not show the node.js command prompt flashing all the time? 如何保持对话框弹出但不显示node.js命令提示符始终闪烁?
Things I have tried: 我尝试过的事情:
I have tried running my script as a service instead of a scheduled task, which keeps the windows command prompt from appearing, but doesn't allow the dialog box to appear to the user (because services run in a different desktop session). 我尝试将脚本作为服务而不是计划任务来运行,这使Windows命令提示符不出现,但不允许该对话框显示给用户(因为服务在另一个桌面会话中运行)。
In normal windows command prompt, you can start a program minimized, using 在正常的Windows命令提示符下,您可以启动最小化的程序,使用
START /MIN [application name] START / MIN [应用程序名称]
and so I tried changing my /tr argument to "start node index.js /MIN" but that didn't work. 因此,我尝试将/ tr参数更改为“ start node index.js / MIN”,但这没有用。
Thanks a bunch in advance for any help! 预先感谢您的帮助!
Whether or not Windows creates a console window for an application is controlled by the Windows Subsystem specified in the binary image (exe file) — something specified at compile time. Windows是否为应用程序创建控制台窗口由二进制映像(exe文件)中指定的Windows子系统 (在编译时指定)控制。
If this is CONSOLE
(as node.js is), Windows creates the console window before the application begins executing. 如果这是CONSOLE
(与node.js一样),则Windows将在应用程序开始执行之前创建控制台窗口。 In other words, it is impossible to control at runtime whether or not a window appears. 换句话说,不可能在运行时控制是否出现窗口。 If WINDOWS
, Windows does not create a console window, as it expects the application to create UI. 如果是WINDOWS
,则Windows不会创建控制台窗口,因为它希望应用程序创建UI。
You will have to create a custom build of the node.js executable with subsystem WINDOWS
. 您将必须使用子系统WINDOWS
创建一个node.js可执行文件的自定义版本 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.