Solved

Run Program with Switches

Posted on 2011-09-19
2
315 Views
Last Modified: 2013-11-27
Hey.

I'm trying to run my app with switches included but seems to error out. Any help?

Here's my code


'Run App

        Try
            Dim Drive As String = System.IO.Path.GetPathRoot(Application.StartupPath)
            Dim App As String = System.IO.Path.Combine(Drive, "\AppDir\App.exe /Switch1 /Switch2")
            Process.Start(App)
        Catch ex As Exception
            MsgBox("App Failed.", MsgBoxStyle.Exclamation)
        End Try

Open in new window

0
Comment
Question by:Here2Help
2 Comments
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 125 total points
Comment Utility
Try it this way:
Try
            Dim Drive As String = System.IO.Path.GetPathRoot(Application.StartupPath)
            Dim App As String = System.IO.Path.Combine(Drive, "\AppDir\App.exe")

            Dim P As New Process
            P.StartInfo.FileName = App
            P.StartInfo.WorkingDirectory = System.IO.Path.GetDirectoryName(P.StartInfo.FileName)
            P.StartInfo.Arguments = "/Switch1 /Switch2"
            P.Start()
        Catch ex As Exception
            MsgBox(ex.ToString, "App Failed.", MsgBoxStyle.Exclamation)
        End Try

Open in new window

0
 
LVL 8

Author Comment

by:Here2Help
Comment Utility
Works a treat.

cheers.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

772 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

12 Experts available now in Live!

Get 1:1 Help Now