Kinook Software Forum

Go Back   Kinook Software Forum > Visual Build Professional > [VBP] User Tips, Tricks and Samples

Thread Tools Rating: Thread Rating: 8 votes, 5.00 average. Display Modes
Old 04-12-2007, 08:30 AM
JC1455 JC1455 is online now
Registered User
Join Date: 11-10-2005
Posts: 8
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.
Reply With Quote
Old 04-12-2007, 12:50 PM
kevina kevina is online now
Registered User
Join Date: 03-26-2003
Posts: 825
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.
Attached Files
File Type: zip wait for (952 Bytes, 4173 views)
Reply With Quote
Old 04-12-2007, 12:56 PM
JC1455 JC1455 is online now
Registered User
Join Date: 11-10-2005
Posts: 8
Thanks! That's exactly what I was looking for!
Reply With Quote
Old 04-03-2019, 03:33 PM
deramor deramor is online now
Registered User
Join Date: 05-11-2011
Posts: 27
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
Reply With Quote
Old 04-03-2019, 04:40 PM
kinook kinook is online now
Join Date: 03-06-2001
Location: Colorado
Posts: 6,033
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.
Reply With Quote

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

All times are GMT -5. The time now is 09:59 PM.

Copyright 1999-2023 Kinook Software, Inc.