Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Process Start Info

Posted on 2010-09-06
5
Medium Priority
?
362 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

Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!

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 …
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

704 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