Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

TASKLIST and @pidwow64

Aug
2,320
111
Hey @Charles Dye
Thanks for adding the ability to show filename extensions with TASKLIST

Nicer with the extensions now, when I look for 32-bit programs;
Code:
R:\>tasklist /e /nx | ffind /kvmt"»"
 4820  ↑» ss_conn_service2.exe  SAMSUNG Mobile Connectivity Service V2
 4828  ↑» ss_conn_service.exe   SAMSUNG Mobile Connectivity Service
 4948  ↑» mainserv.exe          APC UPS Service
 5508  ↑» dataserv.exe          APC Data Service
 7636  ↑» SAService.exe         Samsung Account
 3688   » apcsystray.exe        System Tray Application
 1836  ↑» RightNote.exe         DJ2021.rnt - RightNote

Thanks also for the @pidwow64 function.

Ref: https://charlesdye.net/dl/tasks.zip

Joe
 
Is that really useful? I wanted to see how many processes did not end in .EXE, but nearly all do.

And searching for 32-bit processes, is that something that you do often?
 
Now I know that the processes actually do end in .EXE,
instead of wondering if they do.

As for 32-bit processes,
it helps me when I am working with multiple versions of the same compiler,
at the same time;
Code:
R:\>tasklist /e /nx purebasic*
18124  ↑  PureBasic.exe         PureBasic 6.10 LTS (x64) - ascript.pb
17444  ↑» PureBasic.exe         PureBasic 6.10 LTS (x86) - ascript.pb
 1432     PureBasic.exe         PureBasic 6.10 LTS (x64) - dbf64.pb

   Found 3 processes.

Code:
U:\>tasklist /e /nx vbsedit*
 9140  ↑  vbsedit.exe           Untitled.vbs - VbsEdit
15160  ↑» vbsedit.exe           Untitled.vbs - VbsEdit

   Found 2 processes.

Searching for 16-bit processes is easy,
since I just have to filter msdos

Code:
E:\Utils>tasklist /l/m/nx msdos*
10256     40509440  msdos.exe             msdos.exe -d -e dbase.exe
22156     40534016  msdos.exe             msdos.exe -d -e command.com

   Found 2 processes.

As I work with multiple desktops,
this makes it easier for me to know
that I do have a process open
that I cannot see in the Windows Taskbar
which means it must be on another desktop.

It would be great to know which process is on which desktop.

Joe
 
According to Microsoft CoPilot;

This code snippet opens a process,
retrieves its thread ID,
and then gets the desktop handle associated with that thread.

You can replace 1234 with the actual process ID you want to check.

Code:
#include <windows.h>
#include <iostream>

int main() {
    DWORD processId = 1234; // Replace with your process ID
    HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, processId);
    if (hProcess) {
        DWORD threadId = GetProcessId(hProcess);
        HDESK hDesk = GetThreadDesktop(threadId);
        if (hDesk) {
            std::cout << "Process is on desktop: " << hDesk << std::endl;
        } else {
            std::cerr << "Failed to get desktop handle." << std::endl;
        }
        CloseHandle(hProcess);
    } else {
        std::cerr << "Failed to open process." << std::endl;
    }
    return 0;
}

Joe
 
That doesn't look difficult. But when I look up GetThreadDesktop() in Microsoft's docs, I see that it's supported from Windows 2000. In other words, this is not the Virtual Desktops feature in Windows 10. It probably is not what you want at all.

Microsoft's documented API for the new Virtual Desktops feature is ... flaccid. There is an undocumented interface, but MS seems to change it in every new release of Windows, making it pretty much unusable for anybody not Microsoft. (You may have noticed that WINDOW DESKTOP does not work. I've convinced myself that this is (a) not Rex's fault, and (b) not something that he can really work around.)
 
Yes, the term I should have searched for is Virtual Desktops.

The interface is documented, and I can do this using C# (.NET)

You are correct about Microsoft changing the API with every windows release;
With Windows 11 23H2 Release 3085 Microsoft did change the API (COM GUIDs) for accessing the functions for virtual desktops again.

I provide five versions of virtualdesktop.cs now:
virtualdesktop.cs is for Windows 10,
virtualdesktop11.cs is for Windows 11,
virtualdesktop11-24h2.cs for Windows 11 24H2 Insider,
virtualdesktopserver2022.cs is for Windows Server 2022,
virtualdesktopserver2016.cs is for Windows Server 2016.

Code:
R:\>tasklist vbsedit*
13388  vbsedit           Untitled.vbs - VbsEdit

   Found 1 process.

R:\>VirtualDesktop.exe /GetDesktopFromWindow:13388
Window is on desktop number 0 (desktop 'Desktop 1')

Move vbsedit.exe to next virtual desktop...

Code:
R:\>VirtualDesktop.exe /GetDesktopFromWindow:13388
Window is on desktop number 1 (desktop 'Desktop 2')

Code:
/IsWindowOnDesktop:<s|n>  check if process with name <s> or id <n> is on
                   desktop with number in pipeline (short: /iwod). Returns 0
                   for yes, 1 for no.

Ref: GitHub - MScholtes/VirtualDesktop: C# command line tool to manage virtual desktops in Windows 10

Joe
 
Hey @Charles Dye,
Thanks for the update to Tasks 1.0 Build 27
Code:
U:\>tasklist /e /nx /v vbsedit* 
14428  ↑  vbsedit.exe           <Desktop 1>  Untitled.vbs - VbsEdit
14872  ↑» vbsedit.exe           <Desktop 2>  test.vbs - VbsEdit

   Found 2 processes.

This now clearly shows that I am runing my 32-bit applications in Desktop 2.

Thanks!

Joe
 
How could I miss it?

From my TCSTART.btm;
Code:
:: Added on 2023/12/10
:: See the latest plugins from Charles Dye
@iff %_dowi eq 1 then
  @input /k"YyNn" Would you like to check for the latest plugins from Charles Dye? %%YNFlag
  @iff %YNFlag eq y then
    @echo Checking for the latest plugins from Charles Dye
    call e:\utils\Prospero.btm
  @endiff
@endiff
@if defined YNFlag unset YNFlag

Joe
 
Heh. I have a batch file to download new stuff from Vincent's site (not called from TCStart, though.) The batch file is of course GetLucky.btm....
 
Hey @Charles Dye
Thanks for adding the ability to show filename extensions with TASKLIST

Nicer with the extensions now, when I look for 32-bit programs;
Code:
R:\>tasklist /e /nx | ffind /kvmt"»"
 4820  ↑» ss_conn_service2.exe  SAMSUNG Mobile Connectivity Service V2
 4828  ↑» ss_conn_service.exe   SAMSUNG Mobile Connectivity Service
 4948  ↑» mainserv.exe          APC UPS Service
 5508  ↑» dataserv.exe          APC Data Service
 7636  ↑» SAService.exe         Samsung Account
 3688   » apcsystray.exe        System Tray Application
 1836  ↑» RightNote.exe         DJ2021.rnt - RightNote

Thanks also for the @pidwow64 function.

Ref: https://charlesdye.net/dl/tasks.zip

Joe

Thanks for providing your extension! That's a helpful tool indeed.
 
Heh. I have a batch file to download new stuff from Vincent's site (not called from TCStart, though.) The batch file is of course GetLucky.btm....
Is that a reference to lucky.syr.edu? Lucky hosted my FTP server for many years.
 
I just access my Vince: drive...
Code:
U:\>alias vince:
ftp://vefatica.net

U:\>dir vince: /od

 Directory of  ftp://vefatica.net/*

2014-08-08   0:00       3,657,325  arnex4.JPG
2021-02-17   0:00          45,706  shellex.zip
2022-07-26   0:00         <DIR>    experimental
2022-08-30   0:00         120,245  pset3264.zip
2022-12-02   0:00         <DIR>    4plugins
2023-03-15   0:00          74,062  rundown.zip
2023-04-03   0:00          48,361  ruler.zip
2023-07-02   0:00             213  web.config
2023-07-10   0:00          72,938  conmode.zip
2023-08-02   0:00          66,406  rndmfile.zip
2023-08-02   0:00          73,943  split.zip
2024-02-09   0:00          79,714  regfind.zip
           4,238,913 bytes in 10 files and 2 dirs.

...or...
Code:
U:\>dir vince:\4plugins\x64 /od

 Directory of  ftp://vefatica.net\4plugins\x64/*

2014-12-02   0:00          90,620  4autotray64.zip
2018-08-31   0:00          69,707  sysutils64.zip
2019-04-04   0:00         222,761  onig64dll.zip
2020-02-15   0:00         <DIR>    OldStuff
2021-08-22   0:00           4,728  4autotray64-new.zip
2021-08-28   0:00          80,924  4console64.zip
2023-06-12   0:00          60,494  es.zip
2023-07-02   0:00         <DIR>    .
2023-07-02   0:00         <DIR>    ..
2023-07-02   0:00             169  web.config
2024-04-11  14:24          77,316  4wt.zip
2024-05-16   0:06         173,829  4utils64.zip
             780,548 bytes in 9 files and 3 dirs.

Joe
 
I'd love if e:\utils\Prospero.btm and GetLucky.btm were posted....
 
I'll put this up, but I honestly don't know whether it will be of any use to anyone. It's... idiosyncratic. The batch file doesn't just download files from Vincent's site. It also (a) reads obscured passwords from an .INI file, in order to (b) update a mirror of Vincent's stuff on a server of my own. It's probably way too complicated to serve as an example.
 

Attachments

Back
Top