Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have created a task on Windows Task Scheduler to run a command-line app everytime I lock this machine. It works like a charm.

My question is: Is it possible to see the Command Prompt window when I unlock?

Note: This command line app will never finish by itself. It has to be stopped manually.

share|improve this question
    
@douglaslps Mmm, you should still see the prompt if you unlock the station. At least i tried it here with cmd.exe. If i put that in a on lock workstation and unlock it the cmd.exe is still visible. What user-level did you use? "run only as user is logged on" and not "run with highest priv." and not "hidden"? BTW You should remove the Is it possible to stop the task automatically when I unlock? from your question. If you stop the task automatically it will disappear. –  Rik Dec 20 '13 at 11:45
    
CMD remains visible for me when I log off and on... –  Dave Rook Dec 20 '13 at 11:46
    
Should I run cmd.exe instead of myApp.exe directly? How can I pass myApp as argument to cmd.exe? –  douglaslps Dec 20 '13 at 11:48
    
@rik It is run only as user is logged on and not hidden. –  douglaslps Dec 20 '13 at 11:49
1  
@douglaslps No need for a bounty. If you're happy with the answer you can upvote and accept it. –  Rik Dec 20 '13 at 12:43

1 Answer 1

up vote 1 down vote accepted

We were not exactly sure about the behavior of myApp.exe.

When starting a cmd.exe and execute myApp.exe, if it directly returns to the C-prompt, it is a "background" app. (i.e. it goes directly to the background). In that case, if you use myApp.exe directly in the Task-scheduler, there is no prompt to return to. (That appears to be the case here)

You can keep the prompt open if you start cmd.exe in the Task-Scheduler. You can do that by putting cmd.exe in the run-line-box and /K myApp.exe in the parameter-box. You will be returned to the C-prompt after unlocking. In that prompt you can use TASKKILL /F /IM myApp.exe.exe /T to kill myApp.exe (or if the myApp.exe has a kill-switch, use that).

For others using an app which doesn't return to the C-prompt:

If the myApp.exe does have output in cmd.exe and does not return to the C-prompt you can use /C myApp.exe. Because myApp.exe will keep the prompt open. A Ctrl+C will likely terminate myApp.exe and also exit the prompt.

If /K was used in this case you will be returned to the C-prompt (having to do an extra exit-command to exit the prompt).

Note for CMD.EXE:

/C      Carries out the command specified by string and then terminates
/K      Carries out the command specified by string but remains
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.