Running external programs

# This script executes an external program. 
# In this case, this is the equivalent to either:
#  * [window key]+[r] and entering "http://google.com" 
#  *  entering the url on an 'explorer' window

#Script Parameters
program = 'explorer'
url = 'http://google.com'

#A. We need the Process class to execute external programs
from System.Diagnostics import Process

#B. Create new process instance
p = Process()

#B.1 Configure your process
p.StartInfo.UseShellExecute = False
p.StartInfo.RedirectStandardOutput = True
p.StartInfo.FileName = program
p.StartInfo.Arguments = url

#C. Start the process and wait 
p.Start()
p.WaitForExit() 

Previous
Next Post »