Jump to content
Macro Express Forums

How to get executable name and path.


Recommended Posts

I can use the Variable Set String > Topmost Program Name to get the name of the EXE but it does not include the path. Any idea how we get the path too? My goal is to determine what version of Outlook is running.

Link to comment
Share on other sites

I can use the Variable Set String > Topmost Program Name to get the name of the EXE but it does not include the path. Any idea how we get the path too? My goal is to determine what version of Outlook is running.

Try this macro, that contains a small short Autoit script. It prompts you for part of a currently running process name, and returns the path for the first such process it finds.

Adapt as you see fit!

<VARIABLE SET STRING Option="\x01" Destination="%sProcess%" Prompt="Enter part of the name of any running process\r\n(note that the path returned will be for the first process found containing your entered string)" Mask="FALSE" OnTop="FALSE" Left="Center" Top="Center" Monitor="0"/>
<EXTERNAL SCRIPT Language="AutoIt" Dest="%sPath%" Script="If $CmdLine[0] <> 1 Then Exit\r\n$oWmi = ObjGet(\"winmgmts:\\\\.\\root\\CIMV2\")\r\n$oItems = $oWmi.ExecQuery(\"SELECT * FROM Win32_Process\")\r\nFor $oItem In $oItems\r\n  If StringInStr($oItem.Name, $CmdLine[1]) > 0 Then ExitLoop\r\nNext\r\nConsoleWrite($oItem.ExecutablePath)\r\n\r\n" Parameters="%sProcess%"/>
<TEXT BOX DISPLAY Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang3081{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs16 Process \\b %sProcess%\\b0  can be found in\r\n\\par	 %sPath%\\f1 \r\n\\par }\r\n" Left="Center" Top="Center" Width="500" Height="200" Monitor="0" OnTop="FALSE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/>

Link to comment
Share on other sites

Thanks Paul but late last night a friend of mine and I worked out a VBScript to get the version using the External Script command. It only woks in for Outlook but it's pretty slick. Check it out:

Dim OutlookObject
Set OutlookObject = CreateObject("Outlook.Application")
If OutlookObject Is Nothing Then WScript.StdOut.Write "0" Else WScript.StdOut.Write OutlookObject.Version
Set OutlookObject = Nothing

The other method I came up with was to use the registry to look up which app was associated. In this case looking at the MSG file attachment at HKCR\msgfile\shell\Open\ which points me to the proper Outlook.exe where I could then use the Set Integer to File Version.

 

So for this instance we're set but I will remember your solution as I can definitely see a possible need for this in the future for other applications.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...