I am trying to write a script (python) to open an external exe file on the server once I click on a feature in ArcGIS. The script must have 2 parameters in namely FacilityId and UserID. The exe file will take the parameters and write it to an SQL table where another function triggers from.

This is the python script I have thus far... (Please forgive, me I have not clue what I am doing):

import webbrowser
def OpenLink ( [FacilityId] ):
  path = "W://QGIS//PREMISQGIS.exe" 

The above script at least opens the exe and asks if I want to run it - as soon as I do, it says it doesn't have parameters?

1 Answer 1


You cannot use the webbrowser module to run an executable (I think? Or at least you shouldn't if you can). That is meant to open web pages. Instead, Have a look at the subprocess module. I think you can call this executable with the Facility ID and User Id like this:

import subprocess

def openLink(facilityId, userId):
    path = r"W:\QGIS\PREMISQGIS.exe"
    cmd = '%s %s %s' %(path, facilityId, userId)
    proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    return proc

if __name__ == '__main__':

    # add your parameters here:
    facilityId = 'facility1'
    userId = 'your_name'
    openLink(facilityId, userId)

Please note that you can accomplish the same thing with a simple batch file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.