Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3360920
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T03:03:54+00:00 2026-05-18T03:03:54+00:00

In a batchscript, I need to get a list of process IDs with given

  • 0

In a batchscript, I need to get a list of process IDs with given binary path C:\path\to\binary.exe.
In Linux, I can just do pidof /path/to/binary.

Is there a Win32 executable which does the same, supported from WinXP Home to Win7 (tasklist won’t work)?

The package which includes this has to be portable, so a 10MB download is not what I’m looking for.

Is there a C function available which does this and is supported from WinXP to Win7? Note: I want to match a process path, not a filename which could be used by other applications too.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T03:03:59+00:00Added an answer on May 18, 2026 at 3:03 am

    You can use Toolhelp APIs to enumerate processes, get their full path and compare it with the required process name. You need to walk the modules list for each process. The first module in the list is the process executable itself. Here’s a sample code:

    int main( int argc, char* argv[] )
    {
    
        if( argc > 1 )
        {
            printf( "\nGetting PID of: %s\n", argv[1] );
            HANDLE hProcSnapshot = ::CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 );
            if( INVALID_HANDLE_VALUE != hProcSnapshot )
            {
                PROCESSENTRY32 procEntry = {0};
                procEntry.dwSize = sizeof(PROCESSENTRY32);
                if( ::Process32First( hProcSnapshot, &procEntry ) )
                {
                    do
                    {
                        HANDLE hModSnapshot = ::CreateToolhelp32Snapshot( TH32CS_SNAPMODULE, procEntry.th32ProcessID );
                        if( INVALID_HANDLE_VALUE != hModSnapshot )
                        {
                            MODULEENTRY32 modEntry = {0};
                            modEntry.dwSize = sizeof( MODULEENTRY32 );
                            if( Module32First( hModSnapshot, &modEntry ) )
                            {
                                if( 0 == stricmp( argv[1], modEntry.szExePath ) )
                                {
                                    printf( "\nPID: %ld\n", procEntry.th32ProcessID );
                                    ::CloseHandle( hModSnapshot );
                                    break;
                                }
                            }
                            ::CloseHandle( hModSnapshot );
                        }
                    }
                    while( ::Process32Next( hProcSnapshot, &procEntry ) );
                }
                ::CloseHandle( hProcSnapshot );
            }
        }
        return 0;
    }
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm normally a Linux guy, but I need to write a batch script on
Is there any way to get at Java internal properties, such as sun.arch.data.model ,
I'm working in a windows environment (my laptop!) and I need a couple of
In a Windows (Windows XP) batch script I need to format the current date and
I'm trial and erroring a trivial batch script: I need to execute the .bat
I need help with writing a batch script for if file newfile.txt exists then
I have a Windows batch script (my.bat) which has the following line: DTBookMonitor.exe 2>&1
I need to execute from Java a batch script, which does following 1) Once
I need a batch file that monitors additions to my Downloads folder, but only
Sync of Employees or any other AD group and SharePoint 2007 Currently there is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.