Results 1 to 6 of 6

Thread: ProcessStartInfo.WorkingDirectory for application which is started by another app

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2013
    Posts
    285

    ProcessStartInfo.WorkingDirectory for application which is started by another app

    I have situation where i run an application(APP2.exe) from one of my own application(APP1.exe) by using process.start . But ProcessStartInfo.WorkingDirectory in the application APP2.exe gives path of parent process i.e path of APP1.exe . why is it so? What is the solution for this?

  2. #2
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,289

    Re: ProcessStartInfo.WorkingDirectory for application which is started by another app

    Can you show the code in APP1.exe for starting APP2.exe?
    Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
    - Abraham Lincoln -

  3. #3
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,398

    Re: ProcessStartInfo.WorkingDirectory for application which is started by another app

    *edit: OP notice how the first Two posts at roughly have said "show us your code", you would likely have resolved this thread now if you take the time when posting new questions. Posting code is a big part of your question.

    Can you show me your code.

    vb Code:
    1. Public Class Form1
    2.  
    3.     Private m_process As Process
    4.  
    5.     Private Sub ProcessStart(ByVal fileName As String)
    6.         Dim procInfo As New ProcessStartInfo(fileName) With
    7.             {
    8.                 .WindowStyle = ProcessWindowStyle.Normal,
    9.                 .UseShellExecute = True,
    10.                 .WorkingDirectory = IO.Path.GetDirectoryName(fileName)
    11.             }
    12.  
    13.         Me.m_process = Process.Start(procInfo)
    14.  
    15.         Debug.WriteLine(procInfo.WorkingDirectory)
    16.     End Sub
    17.  
    18. End Class

  4. #4
    New Member
    Join Date
    Feb 2014
    Location
    United States
    Posts
    15

    Re: ProcessStartInfo.WorkingDirectory for application which is started by another app

    I don't know what language your using, nor know exactly how your having an issue without seeing any codes. In VB.net you can do something like:


    Code:
            Dim app As New System.Diagnostics.ProcessStartInfo
            app.FileName = "App2.exe"
            app.WorkingDirectory = "C:\Your\FolderPath"
            System.Diagnostics.Process.Start(app)
    Shot in the dark

  5. #5
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,532

    Re: ProcessStartInfo.WorkingDirectory for application which is started by another app

    Quote Originally Posted by IT researcher View Post
    I have situation where i run an application(APP2.exe) from one of my own application(APP1.exe) by using process.start . But ProcessStartInfo.WorkingDirectory in the application APP2.exe gives path of parent process i.e path of APP1.exe . why is it so? What is the solution for this?
    Why? Because the current working directory isn't the same as the application's StartupDirectory... consider this: I drop into the Commandline... I then CD \ and go up to the root folder...
    I then proceed to
    CD USers\TechGnome
    I'm C:\USers\Techgnome is now my working directory... now I do this:
    C:\Apps\Tools\notepad.exe somefile.txt

    that then goes to the app \ tools folder and runs notepad.exe and passes somefile.txt in...my working directory is still users\Techgnome... so when notepad loads, it's going to look in the users\techgnome folder for somefile.txt... because that' the working directory. But it's startup directory is could to be apps\tools ... there's a difference between where did I start from, vs what is the current folder context? Since you app1.exe was the initial startup, the app2.exe working folder is inherited... but I'd imagine you looked at StartupDirectory it would match what you were expecting.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  6. #6
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,398

    Re: ProcessStartInfo.WorkingDirectory for application which is started by another app

    Quote Originally Posted by Stressin' View Post
    I don't know what language your using, nor know exactly how your having an issue without seeing any codes. In VB.net you can do something like:


    Code:
            Dim app As New System.Diagnostics.ProcessStartInfo
            app.FileName = "App2.exe"
            app.WorkingDirectory = "C:\Your\FolderPath"
            System.Diagnostics.Process.Start(app)
    Shot in the dark
    It's a vb.net section. Chances are it's VB

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width