Kinook Software Forum

Go Back   Kinook Software Forum > Visual Build Professional > [VBP] User Tips, Tricks and Samples
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Rating: Thread Rating: 9 votes, 5.00 average. Display Modes
  #1  
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
  #2  
Old 04-12-2007, 12:50 PM
kevina kevina is online now
Registered User
 
Join Date: 03-27-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 processid.zip (952 Bytes, 6208 views)
Reply With Quote
  #3  
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
  #4  
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.
***Redacted***
Windows Version: Windows 7 Professional
Install path: C:\Program Files (x86)\VisBuildPro9
HideConsole.exe version 1.0.0.0
SftPrintPreview_IX86_U_20.dll version 2.04
VisBuildCmd.exe version 9.7.0.4
VisBuildPro.exe version 9.7.0.5
VisBuildAct.dll version 9.7.0.5
VisBuildCore.dll version 9.7.0.4
VisBuildDotNET.dll version 9.7.0.0
VisBuildExt.dll version 9.7.0.4
VisBuildInf.exe version 9.7.0.4
VisBuildMisc.dll version 9.7.0.4
VisBuildMS.dll version 9.7.0.4
VisBuildMS2.dll version 9.7.0.2
VisBuildNet.dll version 9.7.0.4
VisBuildSvr.dll version 9.7.0.5
VisBuildVCS.dll version 9.7.0.4
Reply With Quote
  #5  
Old 04-03-2019, 04:40 PM
kinook kinook is online now
Administrator
 
Join Date: 03-06-2001
Location: Colorado
Posts: 6,034
It's not really a Visual Build question. Paste the following into a text file.

Code:
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"
	Else
		For Each objProcess in colProcesses
    		FindProcesses = FindProcesses & vbCrLf & objProcess.ProcessID
		Next
	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
Reply


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 06:58 AM.


Copyright © 1999-2023 Kinook Software, Inc.