Solved

Process Start Info

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

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 …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

759 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now