Solved

Process Start Info

Posted on 2010-09-06
5
357 Views
Last Modified: 2012-08-13
This is driving me mad....

i have a 3rd party application that i can call to load xml into a archive system to create pdf's ect i can call this from a cmd line like

3rdpartyapp.exe -s192.2.2.1 -p2000 -j1212 < c:\temp\mydoc.xml

this happily works. i'm now trying to incorporate this into a vb.net app in vs2005.

The example below works fine on 32bit machines but not on 64bit.

So i then tried to call 3rdpartyapp.exe from the ProcessStartInfo and pass the arguments but it seems i cannot pass '<' in the arguments for the input file.

Any ideas?
sSeerver = "192.2.2.1"
sServerPort = "2000"
sJob = "1212"
sDoc = "C:\Temp\MyDoc.xml"

 Dim psi As ProcessStartInfo = New ProcessStartInfo("cmd.exe")
            With psi
                .WindowStyle = ProcessWindowStyle.Hidden
                .WorkingDirectory = AppPath()
                .UseShellExecute = False
                .CreateNoWindow = False
                .RedirectStandardInput = True
                .RedirectStandardOutput = True
                .RedirectStandardError = True
            End With

            Dim m_Input As String = "3rdpartyapp -s" & sServer & " -p" & sServerPort & " -j" & sJob & " < " & sDoc

            Dim m_Process As Process = Process.Start(psi)

            m_Process.StandardInput.WriteLine(m_Input)
            m_Process.Close()

Open in new window

0
Comment
Question by:IanPaskin
  • 2
  • 2
5 Comments
 
LVL 12

Expert Comment

by:GMGenius
ID: 33612473
You could try setting your application to be 32bit
in the project properties page, select the "Compile" table then click on "Advanced Compile Options" change the "AnyCPU" to "x86"
Try again.
I have seen issues with running .NET apps on 64bit where a component it uses is 32bit only.
0
 
LVL 8

Expert Comment

by:PagodNaUtak
ID: 33614408
Try my function below:
Use it this way
sSeerver = "192.2.2.1"  
sServerPort = "2000"  
sJob = "1212"  
sDoc = "C:\Temp\MyDoc.xml"
Dim Result as String = String.Empty
Dim Arguments as String = "-s" & sServer & " -p" & sServerPort & " -j" & sJob & " < " & sDoc

Result = ExecuteApplication("3rdpartyapp", Arguments)

Public Function ExecuteApplication(ByVal ExecutableName As String, ByVal Arguments As String) As String
        Dim Output As String = String.Empty
        Using ExecutableProcess As New Process
            Dim startInfo As New ProcessStartInfo(ExecutableName)
            startInfo.RedirectStandardInput = True
            startInfo.RedirectStandardOutput = True
            startInfo.UseShellExecute = False
            startInfo.CreateNoWindow = True
            startInfo.WindowStyle = ProcessWindowStyle.Hidden
            startInfo.Arguments = Arguments

            ExecutableProcess.StartInfo = startInfo
            ExecutableProcess.Start()

            Output = ExecutableProcess.StandardOutput.ReadToEnd

            ExecutableProcess.WaitForExit()
            ExecutableProcess.Close()

        End Using
        Return Output
End Function

Open in new window

0
 

Author Comment

by:IanPaskin
ID: 33615714
GMGenius: tried the anyCPU the problem i get then is i use oracle.dataaccess in my app and setting to anyCPU causes a whole new set of issues, i might write a quick app just to call the application with no oracle functions and see if setting to anyCPU works then i will have to try and solve teh oracle issues.

PagodNaUtak: nice code for calling the app but it still fails to upload the xml doc so i guess it still doesn't like the ' < ' in the arguments. i will keep trying.

Ian
0
 
LVL 12

Expert Comment

by:GMGenius
ID: 33616167
What is the < for?
0
 

Accepted Solution

by:
IanPaskin earned 0 total points
ID: 33751815
Still couldn't get it to work so i used


Dim Arguments as String = "-s" & sServer & " -p" & sServerPort & " -j" & sJob & " < " & sDoc
Shell("cmd /c" & " " & Arguments )

This works fine but i have less control on the process.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question