Windows 10: What are Tasklist and Taskkill commands in Windows 10

Discus and support What are Tasklist and Taskkill commands in Windows 10 in Windows 10 News to solve the problem; [ATTACH]Sometimes we get into a situation where the Windows Task Manager is not accessible for some reason, or the administrator has disabled it. At... Discussion in 'Windows 10 News' started by WinClub, Sep 6, 2020.

  1. WinClub New Member

    What are Tasklist and Taskkill commands in Windows 10

    WinClub, Sep 6, 2020
    #1
  2. kg415 Win User

    TASKLIST command LIES!

    I have two Windows 10 PCs connected to a NAS via 1Gps Ethernet and run applications such as Thunderbird, Lightroom, Quicken, and others that lock shared network files on the NAS when in use. On sleep, switch user, or lock screen,
    I wish to gracefully stop these apps if running to release the locks. I've not found a reliable way to do this. After trying to use the Windows Event Scheduler, LockandLoad, or Power Triggers to kill tasks when sleep/switch/lock events are detected, I've
    concluded this approach is futile: if a task doesn't clean up quickly enough after receiving a TASKKILL notification, it will be suspended with the shared files left in an unusable state.

    So to avoid this race condition, I wrote a batch script (below) that runs TASKKILL to end a list of applications, then loops running a TASKLIST command until the killed tasks are no longer listed, then runs a sleep/switch/lock command.
    I disabled the standard sleep and lock start menu items (haven't found a way to disable switch user), and created shortcuts to this script with appropriate arguments.

    It STILL does not work reliably. The only explanation I can think of is that the TASKLIST command must not be returning accurate info.

    What to do?

    @Echo off

    rem Kill tasks that lock shared files, then sleep, switch user, or lock session

    rem Usage:

    rem powersafe {sleep|switch|lock} task1 task2 ...

    rem

    rem Installation:

    rem Copy powersafe.bat to C:\Program Files\PowerSafe

    rem Copy sleep.lnk, switch.lnk, lock.lnk to:

    rem C:\ProgramData\Microsoft\Windows\Start Menu\Programs\PowerSafe

    rem Download and install tsdiscon.exe in %SystemRoot%\System32 if necessary.

    if [%1]==[] (

    echo Usage: powersafe {sleep^|switch^|lock} task1 task2 ...

    exit /b 1

    )

    setlocal EnableExtensions

    set tasklist=

    :KILLTASKS

    if [%2]==[] goto KILLDONE

    taskkill /fi "USERNAME eq %USERNAME%" /im %2

    if errorlevel 0 set tasklist=%tasklist% %2

    shift /2

    goto KILLTASKS

    :KILLDONE

    for /f "tokens=4 delims= " %%G in ('tasklist /fi "IMAGENAME eq tasklist.exe" /nh') do SET id=%%G

    :WAIT

    tasklist /nh /fi "Session eq %id%" | findstr /i "%tasklist%"

    if errorlevel 1 (

    goto SLEEP

    )

    timeout /t 1 /nobreak

    goto WAIT

    :SLEEP

    echo %1

    if /i %1==sleep (

    Rundll32.exe Powrprof.dll,SetSuspendState Sleep

    ) else if /i %1==switch (

    %SystemRoot%\System32\tsdiscon.exe

    ) else if /i %1==lock (

    rem Does NOT lock! -- same as tsdiscon.exe

    rundll32.exe user32.dll,LockWorkStation

    )
     
    kg415, Sep 6, 2020
    #2
  3. yok33 Win User
    Tasklist problem. Please help.

    I tried the following steps to get a list of the processes running on my computer. I actually found it on the Microsoft Windows support website.

    "use the command line command tasklist. For example, in

    Start >Run, type

    tasklist /FO CSV>C:\tasklist.csv [click OK]

    This will produced an Excel spreadsheet of the Task Manager information"

    It seems to run fine, but I have absolutely no idea as to WHERE the list goes to? I cannot find it!

    If someone can help me out on this it would be greatly appreciated, or if someone knows a more simple way to get a list of the processes running on my computer, please let me know.

    In the mean time, I will keep pulling the last few hairs out of my head.

    Yok3233
     
    yok33, Sep 6, 2020
    #3
  4. Naki Win User

    What are Tasklist and Taskkill commands in Windows 10

    GPU-Z what command line parameter ?

    Suggestion: /? (-?) and /help (-help) command-line arguments to show a list of all possible arguments in a small window. *Smile What are Tasklist and Taskkill commands in Windows 10 :)
     
    Naki, Sep 6, 2020
    #4
Thema:

What are Tasklist and Taskkill commands in Windows 10

Loading...
  1. What are Tasklist and Taskkill commands in Windows 10 - Similar Threads - are Tasklist Taskkill

  2. What are the basic commands for repairing Windows 10 using the Command Prompt?

    in Windows 10 Gaming
    What are the basic commands for repairing Windows 10 using the Command Prompt?: Can anyone help me in? https://answers.microsoft.com/en-us/windows/forum/all/what-are-the-basic-commands-for-repairing-windows/93916d7d-a073-4bf1-84d6-987c1dfe14c4
  3. What are the basic commands for repairing Windows 10 using the Command Prompt?

    in Windows 10 Software and Apps
    What are the basic commands for repairing Windows 10 using the Command Prompt?: Can anyone help me in? https://answers.microsoft.com/en-us/windows/forum/all/what-are-the-basic-commands-for-repairing-windows/93916d7d-a073-4bf1-84d6-987c1dfe14c4
  4. What are the basic commands for repairing Windows 10 using the Command Prompt?

    in Windows 10 Installation and Upgrade
    What are the basic commands for repairing Windows 10 using the Command Prompt?: Can anyone help me in? https://answers.microsoft.com/en-us/windows/forum/all/what-are-the-basic-commands-for-repairing-windows/93916d7d-a073-4bf1-84d6-987c1dfe14c4
  5. Tasklist/taskkill hangs among other things on Windows Server 2012 R2 x64

    in Windows 10 Gaming
    Tasklist/taskkill hangs among other things on Windows Server 2012 R2 x64: Hi all,I'm writing this as a lowly level 2 tech who has no idea where to go next.I've been having an issue with our backup system reporting that backups have not been happening for this server. This brought me to reinstalling the backup software, but the uninstall process...
  6. Tasklist/taskkill hangs among other things on Windows Server 2012 R2 x64

    in Windows 10 Software and Apps
    Tasklist/taskkill hangs among other things on Windows Server 2012 R2 x64: Hi all,I'm writing this as a lowly level 2 tech who has no idea where to go next.I've been having an issue with our backup system reporting that backups have not been happening for this server. This brought me to reinstalling the backup software, but the uninstall process...
  7. My taskkill stopped working

    in Windows 10 Software and Apps
    My taskkill stopped working: Taskkill worked perfectly, until i tried to update, which failed KB5021233, 0x80242016. After this taskkill stopped working, i tried to kill any process, but it didnt work...
  8. How can I "Close" or "Exit" a task with a command script WITHOUT taskkill /f ?

    in Windows 10 Ask Insider
    How can I "Close" or "Exit" a task with a command script WITHOUT taskkill /f ?: How can I "Close" or "Exit" a task with a command script WITHOUT taskkill /f ? I want to close some tasks, but not force with taskkill. I want to close as if I went to "File" and clicked "Close" or clicked the "X" on the upper right corner of the task window. So task will ask...
  9. RAM Usage: Task Manager vs tasklist

    in Windows 10 Ask Insider
    RAM Usage: Task Manager vs tasklist: Task Manager shows that I'm using 17.5 GB of RAM, but if I run the following from a command prompt: > tasklist /FO csv load the CSV file into excel, then total the Mem Usage column, it only adds up to 8.25 GB. What is using the extra 8.75 GB and why isn't this broken out...
  10. taskkill closes my game.

    in Windows 10 BSOD Crashes and Debugging
    taskkill closes my game.: Hello there! So I decided to play an old game called " cs 1.6 ". Installation was successful, but after I joined a multiplayer/singleplayer match, it opened cmd prompt " taskkill " or something like it. I tried restarting my pc, reinstalling the game, nothing worked. So I...