I'm working on a solution that requires me to use a title as filter in order to ONLY terinate certain CMD sessions.
If I execute the script manually, the session is inclusive of a title.
If executed with Task Scheduler, no title is associated with the cmd session?
Why is this?
Test:
Batch:
Code: Select all
TITLE Jarvis_Landry_is_a_joke
pause
Output:
Code: Select all
Image Name: cmd.exe
PID: 318540
Session Name: RDP-Tcp#0
Session#: 1
Mem Usage: 2,952 K
Status: Running
User Name: PELOTON\Administrator
CPU Time: 0:00:00
Window Title: Administrator: Command Prompt - tasklist /v /fi "imagename eq cmd.exe" /fo list
Image Name: cmd.exe
PID: 278260
Session Name: RDP-Tcp#0
Session#: 1
Mem Usage: 2,884 K
Status: Running
User Name: PELOTON\Administrator
CPU Time: 0:00:00
Window Title: Administrator: Jarvis_Landry_is_a_joke
But when I execute the same script using Task Scheduler, I get N/A for Title:
Code: Select all
Image Name: cmd.exe
PID: 238680
Session Name: Services
Session#: 0
Mem Usage: 128,224 K
Status: Unknown
User Name: PELOTON\srvc-oracle
CPU Time: 0:00:19
Window Title: N/A
Image Name: cmd.exe
PID: 156540
Session Name: RDP-Tcp#0
Session#: 1
Mem Usage: 2,944 K
Status: Running
User Name: PELOTON\Administrator
CPU Time: 0:00:00
Window Title: Administrator: Command Prompt - tasklist /v /fi "imagename eq cmd.exe" /fo list
Does anyone know why?
THanks!