Solved

Process Start Info

Posted on 2010-09-06
5
360 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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 …
A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

751 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