Solved

Process Start Info

Posted on 2010-09-06
5
361 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
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 this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

632 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