J
J
John Smith2020-06-16 22:50:51
Windows
John Smith, 2020-06-16 22:50:51

How can I make the cmd window close when the script ends?

I want to set the monitor to turn off on the button (using nircmd, although the option via PS gave the same result).

did like this:

nircmdc.exe monitor off

start "" "nircmdc.exe" monitor off

start "" /B "nircmdc.exe" monitor off

cmd /c start "" /B "nircmdc.exe" monitor off

cmd "nircmdc.exe" monitor off


I ran it from .bat, and just through Win-R for the sake of experiment.

(yes, this is tambourine dancing in all its glory)

None of the options cause the cmd window to close after the command is invoked.
CHADNT?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yan, 2020-06-16
@ClearAirTurbulence

start nircmd.exe monitor off
tasklist | find "nircmd.exe"
taskkill /f /im nircmd.exe
exit

Why do you need to touch the console version?

start nircmdc.exe monitor off
tasklist | find "nircmdc.exe"
taskkill /f /im nircmdc.exe
exit

The first and last lines are possible, but the program will not be deleted from the task manager
. And if there are other scripts in the system, I think it will be possible to rename nircmd to something else so that taskkill does not kill them when the screen is turned off.
That's all

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question