Solved

Run process on 64-bit server using System.Diagnostics.ProcessStartInfo not working

Posted on 2014-09-23
3
280 Views
Last Modified: 2015-03-10
I need to run an executable which happens to reside on a 64-bit OS. I am attempting to start the process via the ProcessStartInfo function while passing it the path of the executable, and necessary arguments. This is not working. Has anyone successfully done this?

I've tried
Dim FILENAME As String = ""
        FILENAME = "D://wwwroot//[filename]"
       
        Dim path As String = "////[path_location]"
       
        Try

            Dim myProcessStartInfo As New System.Diagnostics.ProcessStartInfo("[program.exe]")
            myProcessStartInfo.Arguments = String.Concat(FILENAME, " """, path, """ [args]")
            System.Diagnostics.Process.Start(myProcessStartInfo)
       

Open in new window

and below code where I pass the command and arguments
Dim p As Process = New Process()
           Dim pi As ProcessStartInfo = New ProcessStartInfo()
            pi.Arguments = command + " " + arguments
            pi.FileName = "cmd.exe"
           

            p.StartInfo = pi
            p.Start()

Open in new window

0
Comment
Question by:tammieR
  • 2
3 Comments
 
LVL 32

Expert Comment

by:it_saige
ID: 40339895
What exception do you receive?

-saige-
0
 

Author Comment

by:tammieR
ID: 40341896
no exception. The executable runs as a service and closes without working correctly. I'm wondering if I'm not passing arguments correctly. My hang up seems to be the direction of the slash for the path locations, and how to many to use. I've tried both C:\ and C://, for example. Which is the correct method?
0
 
LVL 32

Accepted Solution

by:
it_saige earned 500 total points
ID: 40341957
Strictly speaking, VB.NET does not care so much about the forward or the backslash.  C# on the other hand does as the backslash is an escape character.  The file system on the other hand does.  If you are dealing with a Microsoft operating system (which you most likely are), then the path needs to be formatted with backslashes, i.e. - "D:\inetpub\wwwroot\"; etc.

If you were programming this in C#, you would either double up your backslashes or specify an @ symbol in the front of the string (the @ symbol would define the string as a string literal), i.e. - "D:\\inetpub\\wwwroot\\"; or @"D:\inetpub\wwwroot\"; etc.  Since you are using VB.NET "D:\inetpub\wwwroot\" should suffice.

Now concern question, is the executable that you are attempting to run a 'true' service (in that it is registered with the operating system as a service and appears in the services list)?

If this is the case, then you are probably looking to start it using the ServiceController class:

http://msdn.microsoft.com/en-us/library/system.serviceprocess.servicecontroller(v=vs.110).aspx

-saige-
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

705 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

19 Experts available now in Live!

Get 1:1 Help Now