-
Mar 5th, 2014, 09:54 AM
#1
Thread Starter
Hyperactive Member
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?
-
Mar 5th, 2014, 12:10 PM
#2
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 -
-
Mar 5th, 2014, 12:15 PM
#3
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:
Public Class Form1 Private m_process As Process Private Sub ProcessStart(ByVal fileName As String) Dim procInfo As New ProcessStartInfo(fileName) With { .WindowStyle = ProcessWindowStyle.Normal, .UseShellExecute = True, .WorkingDirectory = IO.Path.GetDirectoryName(fileName) } Me.m_process = Process.Start(procInfo) Debug.WriteLine(procInfo.WorkingDirectory) End Sub End Class
-
Mar 5th, 2014, 12:26 PM
#4
New Member
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
-
Mar 5th, 2014, 02:23 PM
#5
Re: ProcessStartInfo.WorkingDirectory for application which is started by another app
Originally Posted by IT researcher
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
-
Mar 5th, 2014, 03:46 PM
#6
Re: ProcessStartInfo.WorkingDirectory for application which is started by another app
Originally Posted by Stressin'
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|