简体   繁体   English

如何在不闪烁命令提示符框的情况下运行Windows任务,但是在需要时仍显示对话框?

[英]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: 我尝试过的事情:

  1. 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命令提示符不出现,但不允许该对话框显示给用户(因为服务在另一个桌面会话中运行)。

  2. 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.

相关问题 需要从命令行运行Windows安全性对话框 - Need to Run Windows Security Dialog Box from Command Line Windows 8.1无法运行批处理文件而没有命令提示符闪烁 - Windows 8.1 unable to run batch file without command prompt flashing 如何在C ++中为对话框实现Windows风格? - How do I implement Windows style for a dialog box in C++? 如何更改命令提示符/控制台窗口/ DOS框中的制表位? - How do I change the tab stops in a Command Prompt/Console window/DOS Box? 从命令提示符或Windows 7/8跳转列表菜单打开sln文件时,如何添加默认的“以管理员身份运行”? - How do I add a default Run As Administrator when I open a sln file from the command prompt or Windows 7/8 Jump List menu? Windows 命令 - 如何删除闪烁的光标(提示?) - Windows command - how to remove flashing cursor (prompt?) 如何在Windows命令提示符中执行“字数统计”命令 - How do I do a “word count” command in Windows Command Prompt 如何在Windows中没有命令提示符的情况下运行nodejs? - How to run nodejs without command prompt in windows? 如何从 windows 命令提示符在虚拟环境中运行 python 程序? - How do I run a python program in a virtual environment from windows command prompt? 在命令提示符下执行 Windows 运行对话框命令 - Execute Windows run dialog command in command prompt
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM