Results 1 to 16 of 16

Thread: [RESOLVED] Process Start not loading needed files

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Apr 2019
    Location
    Sabattus
    Posts
    229

    Resolved [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
    Can't Type - Forgetful - Had Stroke = Forgive this old man!
    My Website
    VSCOMM 2022 LAZARUS 2.2.0 Win10 16G RAM Nivida GForce RTX 2060

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    Apr 2019
    Location
    Sabattus
    Posts
    229

    Re: Process Start not loading needed files

    Also, FYI, the two txt files are in the same location as the exe.
    Can't Type - Forgetful - Had Stroke = Forgive this old man!
    My Website
    VSCOMM 2022 LAZARUS 2.2.0 Win10 16G RAM Nivida GForce RTX 2060

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Apr 2019
    Location
    Sabattus
    Posts
    229

    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.
    Can't Type - Forgetful - Had Stroke = Forgive this old man!
    My Website
    VSCOMM 2022 LAZARUS 2.2.0 Win10 16G RAM Nivida GForce RTX 2060

  4. #4
    PowerPoster jdc2000's Avatar
    Join Date
    Oct 2001
    Location
    Idaho Falls, Idaho USA
    Posts
    2,140

    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

  5. #5
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    33,923

    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
    * 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

    Thread Starter
    Addicted Member
    Join Date
    Apr 2019
    Location
    Sabattus
    Posts
    229

    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.
    Can't Type - Forgetful - Had Stroke = Forgive this old man!
    My Website
    VSCOMM 2022 LAZARUS 2.2.0 Win10 16G RAM Nivida GForce RTX 2060

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Apr 2019
    Location
    Sabattus
    Posts
    229

    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
    Can't Type - Forgetful - Had Stroke = Forgive this old man!
    My Website
    VSCOMM 2022 LAZARUS 2.2.0 Win10 16G RAM Nivida GForce RTX 2060

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Apr 2019
    Location
    Sabattus
    Posts
    229

    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
    Can't Type - Forgetful - Had Stroke = Forgive this old man!
    My Website
    VSCOMM 2022 LAZARUS 2.2.0 Win10 16G RAM Nivida GForce RTX 2060

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    Apr 2019
    Location
    Sabattus
    Posts
    229

    Re: Process Start not loading needed files

    Quote Originally Posted by techgnome View Post
    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
    Can't Type - Forgetful - Had Stroke = Forgive this old man!
    My Website
    VSCOMM 2022 LAZARUS 2.2.0 Win10 16G RAM Nivida GForce RTX 2060

  10. #10
    PowerPoster jdc2000's Avatar
    Join Date
    Oct 2001
    Location
    Idaho Falls, Idaho USA
    Posts
    2,140

    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.

  11. #11

    Thread Starter
    Addicted Member
    Join Date
    Apr 2019
    Location
    Sabattus
    Posts
    229

    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)
    Can't Type - Forgetful - Had Stroke = Forgive this old man!
    My Website
    VSCOMM 2022 LAZARUS 2.2.0 Win10 16G RAM Nivida GForce RTX 2060

  12. #12

    Thread Starter
    Addicted Member
    Join Date
    Apr 2019
    Location
    Sabattus
    Posts
    229

    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
    Can't Type - Forgetful - Had Stroke = Forgive this old man!
    My Website
    VSCOMM 2022 LAZARUS 2.2.0 Win10 16G RAM Nivida GForce RTX 2060

  13. #13
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    33,923

    Re: [RESOLVED] Process Start not loading needed files

    Quote Originally Posted by pixelink View Post
    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.

    Quote Originally Posted by pixelink View Post
    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...

    Quote Originally Posted by pixelink View Post
    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
    * 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??? *

  14. #14
    PowerPoster jdc2000's Avatar
    Join Date
    Oct 2001
    Location
    Idaho Falls, Idaho USA
    Posts
    2,140

    Re: [RESOLVED] Process Start not loading needed files

    This is also why I posted the link to the Process.Start documentation.

  15. #15

    Thread Starter
    Addicted Member
    Join Date
    Apr 2019
    Location
    Sabattus
    Posts
    229

    Re: [RESOLVED] Process Start not loading needed files

    Quote Originally Posted by techgnome View Post
    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
    Can't Type - Forgetful - Had Stroke = Forgive this old man!
    My Website
    VSCOMM 2022 LAZARUS 2.2.0 Win10 16G RAM Nivida GForce RTX 2060

  16. #16

    Thread Starter
    Addicted Member
    Join Date
    Apr 2019
    Location
    Sabattus
    Posts
    229

    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
    Can't Type - Forgetful - Had Stroke = Forgive this old man!
    My Website
    VSCOMM 2022 LAZARUS 2.2.0 Win10 16G RAM Nivida GForce RTX 2060

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