PDA

View Full Version : Command line parameters


pjaquiery
04-16-2004, 12:29 AM
Is it possible to get the command line parameters that were used when VisBuildCmd.exe was invoked?

Ideally the command line (excluding the executable) would be available as a system macro.

kinook
04-18-2004, 09:30 PM
You could use WMI to retrieve this (the text below can be copied/pasted into VBP). It will retrieve the entire command-line, including the executable.

<step action='Run Script' type='0'>
<Language>VBScript</Language>
<Script><![CDATA[Builder.LogMessage "VisBuildCmd command-line = '" & GetCommandLine & "'"

' use WMI to retrieve the command-line of the VisBuildCmd.exe
' process on the current machine (assumes only one running instance)
' see http://msdn.microsoft.com/library/en-us/wmisdk/wmi/win32_process.asp
' for more details
Function GetCommandLine()

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

Set colProcesses = objWMIService.ExecQuery("Select * from Win32_Process Where Name = 'VisBuildCmd.exe'")

For Each objProcess in colProcesses

GetCommandLine = objProcess.CommandLine
Exit Function
Next

End Function
]]></Script>
<indent type='3'>1</indent>
<name>New Step</name>
</step>