Kinook Software Forums

Kinook Software Forums (
-   [VBP] User Tips, Tricks and Samples (
-   -   Wait on Process ID? (

JC1455 04-12-2007 09:30 AM

Wait on Process ID?
I see there is a new feature that I'd like to use. Wait now supports waiting on a running process. However you have to specify the process ID. My question is how can I determine the process ID for a process?

Our build machines start up, run the builds and then shut back down. Our IT runs full virus scans once a week. So after the appointed scan time passes the next time our build machine starts up it begins running the scan. I'd like to change our build script so that after it's done building it waits for the scan to complete before shutting down, but I don't know how to get the process ID so I can use the new wait feature.

Thanks for any suggestions.

kevina 04-12-2007 01:50 PM

1 Attachment(s)
Attached is a small bld file that demonstrates what you are requesting.

This build demonstrates retrieving the process ID for a process not started by Visual Build Professional using WMI (see the FindProcesses Project script function).

Note that this function isn't needed for processes started by Visual Build Professional with a Run Program step since that action puts the ProcessID for the process in the RUNPROGRAM_PROCESSID temporary macro.

JC1455 04-12-2007 01:56 PM

Thanks! That's exactly what I was looking for!

deramor 04-03-2019 04:33 PM

I know this is a really old thread but I was trying to use this wait on a custom exe. The wait step never finds a PID of the exe I provide to it.

At first I thought it was a 32-bit/64-bit thing since I am using the 32-bit version of VBP and a 64-bit exe. I rebuilt the custom exe as a 32-bit binary and it didn't change the behavior.

The output:

Waiting for process(es) '[FindProcesses("COMPUTER", "BuildDoc.exe")]' to exit...
All process(es) already done
4/3/2019 4:27:59 PM: Build successfully completed (elapsed = 00:00:01).

However the process is listed in the Task Manager.
Running the process with application window hidden or not makes no difference.

Any thoughts?
I am running VBP 9.7

Visual Build Professional 9.7
Copyright 1999-2019 Kinook Software, Inc.
Windows Version: Windows 7 Professional
Install path: C:\Program Files (x86)\VisBuildPro9
HideConsole.exe version
SftPrintPreview_IX86_U_20.dll version 2.04
VisBuildCmd.exe version
VisBuildPro.exe version
VisBuildAct.dll version
VisBuildCore.dll version
VisBuildDotNET.dll version
VisBuildExt.dll version
VisBuildInf.exe version
VisBuildMisc.dll version
VisBuildMS.dll version
VisBuildMS2.dll version
VisBuildNet.dll version
VisBuildSvr.dll version
VisBuildVCS.dll version

kinook 04-03-2019 05:40 PM

It's not really a Visual Build question. Paste the following into a text file.


Function FindProcesses(computer, processName)

        Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & computer & "\root\cimv2")

        sql = "SELECT * FROM Win32_Process WHERE Name LIKE '" & processName & "'"
        Set colProcesses = objWMIService.ExecQuery(sql)

        If colProcesses.Count = 0 Then
                FindProcess = "0"
                For Each objProcess in colProcesses
                    FindProcesses = FindProcesses & vbCrLf & objProcess.ProcessID
        End If
End Function

WScript.Echo(FindProcesses("COMPUTER", "builddoc.exe"))

Save as wait.vbs.

Open a Command Prompt to the path where you saved the .vbs file and run

cscript wait.vbs

I did this with cmd.exe instead of builddoc.exe and got a list of process IDs for each running cmd.exe instance.

All times are GMT -5. The time now is 06:02 PM.

Copyright 1999-2022 Kinook Software, Inc.