-
Jul 18th, 2022, 11:51 AM
#1
Thread Starter
Addicted Member
[RESOLVED] Process Start not loading needed files
Hello,
I am using "Process.Start('filename") to launch an exe program.
It launches the program fine.
However, it doesn't load all the two necessary .txt file setting files that is loaded by the exe program.
Yet, If I launch the same program from the taskbar (or start menu).... it loads the .txt setting files fine.
Is there a parameter that I should be using on the "Process.Start" to load all the files the exe file uses and should be loading?
Its like it ignores the txt file using Process.Start
-
Jul 18th, 2022, 11:54 AM
#2
Thread Starter
Addicted Member
Re: Process Start not loading needed files
Also, FYI, the two txt files are in the same location as the exe.
-
Jul 18th, 2022, 12:11 PM
#3
Thread Starter
Addicted Member
Re: Process Start not loading needed files
Also, this seems to do this wit a lot of my own vb apps as well as a few others.
It's like it ignores any program settings.
Even websites that I launch with Process.Start, that uses cookies to keep track of login info is ignored and I have to always log into a website after launching.
This is not normal Windows behavior when launching programs/websites.
-
Jul 18th, 2022, 12:17 PM
#4
Re: Process Start not loading needed files
Post the Process.Start code that you are using.
Do you need to specify the .txt files that the .exe file uses? It would appear that if you are double clicking on a program icon that you should not have to. What folder is the actual.exe file located in? Post the complete path for that file.
https://docs.microsoft.com/en-us/dot...t?view=net-6.0
-
Jul 18th, 2022, 12:27 PM
#5
Thread Starter
Addicted Member
Re: Process Start not loading needed files
1) I already posted the code above. Very simple....
Process.Start(D:\###\###\AudioBible.exe)
2) The two files are (that the EXE loads itself)...
D:\D:\###\###\settings.txt
D:\###\###\favorites.txt
I am double clicking on a ListView. Not button
Why would I have to specify additional files that EXE is loading. Windows doesn't?
If you launch a program on the taskbar, I don't have to add accompaning files that the program loads. You know how crazy that would be for windows users.
That doesn't make sense.
Just so you understand. These are NOT files that I am trying to run with the program the way Process.Start works.
These are files that the EXE program loads during/after launching.
Last edited by pixelink; Jul 18th, 2022 at 12:31 PM.
-
Jul 18th, 2022, 12:24 PM
#6
Re: Process Start not loading needed files
Sounds like maybe the current working directory (CWD) isn't being set correctly... The assumption is that the CWD is where the app is... but that may not be the case. If these apps are something you can control/modify it may be worth putting a MessageBox in there at startup to display the CWD... It wouldn't surprise me to find out that it isn't what you're expecting.
-tg
-
Jul 18th, 2022, 12:41 PM
#7
Thread Starter
Addicted Member
Re: Process Start not loading needed files
No. my VB apps work perfectly fine if I launch them from Windows Taskbar.
Its the Process.Start that is the problem
-
Jul 18th, 2022, 12:42 PM
#8
Thread Starter
Addicted Member
Re: Process Start not loading needed files
Originally Posted by techgnome
Sounds like maybe the current working directory (CWD) isn't being set correctly... The assumption is that the CWD is where the app is... but that may not be the case. If these apps are something you can control/modify it may be worth putting a MessageBox in there at startup to display the CWD... It wouldn't surprise me to find out that it isn't what you're expecting.
-tg
No. my VB apps work perfectly fine if I launch them from Windows Taskbar.
Its the Process.Start that is the problem
-
Jul 18th, 2022, 12:39 PM
#9
Thread Starter
Addicted Member
Re: Process Start not loading needed files
Here is a screenshot
LEFT
Launched from Windows taskbar (hass color and favorites)
RIGHT
Launched from my vb app using Process.Start (no color and no favorites)
I am need something else to launch programs so that it loads all data the app is supposed to load just like in native Windows.
Attachment 185306
-
Jul 18th, 2022, 01:09 PM
#10
Re: Process Start not loading needed files
D:\D:\###\###\settings.txt is an illegal path name. I am betting that you really meant something like this:
D:\123\456\settings.txt
D:\123\456\favorites.txt
Post the code in your application program that actually opens these files so we can see how you are accessing them. Techgnome is probably correct, you are not specifying the actual fill path, but the path for the current working directory, and that is not set correctly when you launch the program using certain methods.
-
Jul 18th, 2022, 01:16 PM
#11
Thread Starter
Addicted Member
Re: Process Start not loading needed files
I figured it out.
I needed to specify the working directory in my Process.Start... not on the other apps.
I found on Windows website that Process Start (without specifying working directory) is just starting its own process, that is why i didn't work.
Now, by adding the working directory to the parameters of the Process.Start call, fixes it. Now it sees the actual starting directory of the launched exe.
Code:
Dim xStr As String
lstVX = lstVPB.SelectedIndices(0)
xStr = lstVPB.Items(lstVX).SubItems(1).Text
Dim PathofYourFile As String = xStr
Dim xPath As String = IO.Path.GetDirectoryName(PathofYourFile)
Dim app As New System.Diagnostics.ProcessStartInfo
app.FileName = xStr
Dim appPath As String = Application.StartupPath()
app.WorkingDirectory = xPath
System.Diagnostics.Process.Start(app)
-
Jul 18th, 2022, 01:22 PM
#12
Thread Starter
Addicted Member
Re: [RESOLVED] Process Start not loading needed files
Thanks for your trying to help.
But, most of you are focused on my app that isn't working, when it was also a lot of other apps, even ones I don't make.
The issues wasn't my app... like I said.. it worked fine when launched from Windows taskbar. Has been for years.
The issue started when I created an app launcher using Process.Start.
Granted, setting a working app in my vb programs would of helped. But, the issue effected other apps I have no control of.
Thus, I had to focus on the issue at hand... Process.Start
-
Jul 18th, 2022, 01:27 PM
#13
Re: [RESOLVED] Process Start not loading needed files
Originally Posted by pixelink
No. my VB apps work perfectly fine if I launch them from Windows Taskbar.
Its the Process.Start that is the problem
That's what I was trying to get at.
Originally Posted by pixelink
I figured it out.
I needed to specify the working directory in my Process.Start... not on the other apps.
I found on Windows website that Process Start (without specifying working directory) is just starting its own process, that is why i didn't work.
Now, by adding the working directory to the parameters of the Process.Start call, fixes it. Now it sees the actual starting directory of the launched exe.
Code:
Dim xStr As String
lstVX = lstVPB.SelectedIndices(0)
xStr = lstVPB.Items(lstVX).SubItems(1).Text
Dim PathofYourFile As String = xStr
Dim xPath As String = IO.Path.GetDirectoryName(PathofYourFile)
Dim app As New System.Diagnostics.ProcessStartInfo
app.FileName = xStr
Dim appPath As String = Application.StartupPath()
app.WorkingDirectory = xPath
System.Diagnostics.Process.Start(app)
Again... that's what I was trying to tell you... the CWD wasn't set...
Originally Posted by pixelink
Thanks for your trying to help.
But, most of you are focused on my app that isn't working, when it was also a lot of other apps, even ones I don't make.
The issues wasn't my app... like I said.. it worked fine when launched from Windows taskbar. Has been for years.
The issue started when I created an app launcher using Process.Start.
Granted, setting a working app in my vb programs would of helped. But, the issue effected other apps I have no control of.
Thus, I had to focus on the issue at hand... Process.Start
I never said your app wasn't working, I simply said that your CWD wasn't correct.... which, yeah, as you found out, is something you have to set as part of the parameters of the Process class before calling .Start.
-tg
-
Jul 18th, 2022, 01:45 PM
#14
Thread Starter
Addicted Member
Re: [RESOLVED] Process Start not loading needed files
Originally Posted by techgnome
That's what I was trying to get at.
Again... that's what I was trying to tell you... the CWD wasn't set...
I never said your app wasn't working, I simply said that your CWD wasn't correct.... which, yeah, as you found out, is something you have to set as part of the parameters of the Process class before calling .Start.
-tg
Sorry for any confusion.
Thanks
-
Jul 18th, 2022, 01:31 PM
#15
Re: [RESOLVED] Process Start not loading needed files
This is also why I posted the link to the Process.Start documentation.
-
Jul 18th, 2022, 01:46 PM
#16
Thread Starter
Addicted Member
Re: [RESOLVED] Process Start not loading needed files
Yeah, I saw that. And it doesn't really address working directories that I saw.
Sorry for any confusion.
Thanks
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
|