PDM Search from the command line

Today I set a goal for myself to figure out a way to search for files in my PDM Pro vault from the command line. It is true that I can start the search tool from the command line. (<install dir>\search.exe), but I wanted something faster. I just want to type the command and a file name, hit enter, and have my file appear in Windows Explorer right before my eyes.

I certainly could create an application with Visual Studio, PDM Pro has a very nice API, but I wanted something lighter…and something that would maybe give you some ideas of other things you could quickly do from the command line.

So I opened notepad and created this file:

if WScript.Arguments.Count = 1 then
	strFileName=WScript.Arguments(0)
	strVaultName = "Production" 'Place the name of your vault here
	Set vault = CreateObject("ConisioLib.EdmVault")
	Call vault.LoginAuto(strVaultName, 0)
	If vault.IsLoggedIn Then
		Set Search = vault.CreateSearch()
		Search.FindFolders = False
		Search.FindFiles = True
		Search.FileName = strFileName
		Set SearchResult = Search.GetFirstResult 'Get the first file I find
		If Not SearchResult Is Nothing Then ' We found a file
			FileID=SearchResult.ID
			FolderID=SearchResult.ParentFolderID
			CreateObject("WScript.Shell").Run("conisio://" & strVaultName & "/explore?projectid=" & FolderID & "&documentid=" & FileID & "&objecttype=1")
		Else
			msgbox strFileName & " not found"
		End If
	End If
ELSE
	msgbox "Incorrect number of arguments"
end if

Then I saved this file as “PDMSave.vbs” (I’m assuming you have visual script enabled/installed.)

This gets technically is all I need. [Certainly I could have assigned the search file name with an input box, instead of using parameters, and that would probably satisfy most people….put the “PDMSave.vbs” file on your desktop, double click on it, the input box asks you for the file name and you’re golden.]

With this file in my “InflowScripts” folder, I hit Windows+R key and type:

wscript c:\InflowScripts\PDMFind.vbs bracket.sld%

, PDM Search from the command line

This would get the first file the search tool finds, opens and highlights the file in Windows Explorer. (wscript, is my preferred Windows scripting host, you can use others)

Note: Wildcards!

Lots of typing at the command line though, so again in notepad I created this file:

wscript %~dp0PDMFind.vbs %1

Then I saved this file as “PDMSearch.bat” in my “InflowScripts” folder.

Now when I hit Windows+R I can type:

c:\InflowScripts\PDMFind bracket.sld%

…a little shorter. After I added the folder “InflowScripts” to my windows PATH environment variable, this if finally pretty useful!

:, PDM Search from the command line

Pure keyboard bliss.

  • Share this
Find Your Design Solution in the CATI Store.
Browse Products