Trouble with System.Diagnostics.Process.Start passing arguments

jbl_ks

Member
Joined
Dec 16, 2010
Messages
24
Programming Experience
Beginner
I am attempting to open a cmd.exe process with the 8 arguments listed
At this point all this does is open a command window in the correct directory

Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.

F:\Python26>

What I want to send to the command window is:
F:\Python26> python.exe globalmaptiles_modified.py 17 32.123365 -95.938098 32.266846 -95.789143 F:\Python26\process_test.txt

And have it execute and create the desired file


Imports System.Net
Imports System.Diagnostics

Public Class Form1

Private Sub btnCallPythonScript_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnCallPythonScript.Click

Dim myProcess As System.Diagnostics.Process = New System.Diagnostics.Process()
myProcess.StartInfo.FileName = "F:\Windows\System32\cmd.exe"
myProcess.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal
myProcess.StartInfo.WorkingDirectory = "F:\Python26\"
myProcess.StartInfo.Arguments = "python.exe globalmaptiles_modified.py 17 32.123365 -95.938098 32.266846 -95.789143 F:\\Python26\\process_test.txt"
myProcess.Start()

End Sub
End Class

I have even tried this with a design Process from the toolbar and set the File, working directory and start info arguments and I get the exact same results. I am not understanding the Argments function or I am doing something wrong and not sending them correctly.
 
cmd.exe requires a special switch to carry out a command, see help about that, but why run cmd.exe when you really want to run python.exe? Run python.exe instead.
 
I had tried quite a while to run python with the arguments with no luck. I thought cmd.exe might be easier, it was not.
I did make some changes and finally got it to work calling the python script.
Thanks
 
Back
Top