问题
My problem is that it seems that on Windows 10 a desktop link (.lnk) that opens a console application in a minimized window makes all windows opened by this console application to be also minimized.
I would like to start Node.js in a minimized console window, but at the same time make Node.js opn
open the browser in a maximized window ( this makes sense, since I'm not interested in the console output, rather I want the output in the browser window ).
opn("http://localhost:9000") // but hey, in maximized window!
Is there any way I can achieve this either by Node.js or by some Windows manipulation?
回答1:
I made it. It is a Windows trick.
Based on this answer:
How do I minimize the command prompt from my bat file
if not DEFINED IS_MINIMIZED set IS_MINIMIZED=1 && start "" /min "%~dpnx0" %* && exit
... script logic here ...
exit
This a trick for a script to run itself in a minimized window. But somehow the property inherited from the .lnk remains maximized, so the browser window opened by the script running in its self minimized window opens the browser maximized.
回答2:
There is a workaround, at least in my used case. But this just minimized the node console only. It will still appear in the taskbar.
I just created a shortcut with
- Target: C:\WINDOWS\system32\cmd.exe /c start /min node < Your Application >
- Start in: < Path to your application >
"Start in" is not required if you specify the full path to your application
Examples:
Target: C:\WINDOWS\system32\cmd.exe /c start /min node "C:\Users\jjyong\Documents\Programming\Node\PriceTracking\app.js"
Or
Target: C:\WINDOWS\system32\cmd.exe /c start /min node app.js
- Start in: C:\Users\jjyong\Documents\Programming\Node\PriceTracking
Note: I have only tested using NodeJS version 12.13.1 with PuppeteerJS running chromium with "headless: false"
来源:https://stackoverflow.com/questions/48175160/can-i-make-node-js-opn-open-the-browser-with-maximized-window-when-node-js-itsel