Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. ProcessStartInfo

ProcessStartInfo

Scheduled Pinned Locked Moved C#
helpcsharp
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Peter Walburn
    wrote on last edited by
    #1

    Hi, I have a C# program that will start another external program (such as notepad). The C# program needs to pass arguments and the working directory to the external program. I have attempted to do this like: Process process = new Process(); try { process.StartInfo.UseShellExecute = false; process.StartInfo.FileName = @"c:\Windows\notepad.exe"; process.StartInfo.Arguments = @"c:\test.txt"; process.StartInfo.WorkingDirectory = @"c:\temp"; process.Start(); process.WaitForExit(); } catch { MessageBox.Show("Error running " + strExe, "Error", MessageBoxButtons.OK); } Notepad does start and opens the correct file, but the Working Directory has not been set. I have tried setting the current directory of the C# applicaiton, then running the notepad process, but the Working Directory is still not set. Please help! Pete

    B S 2 Replies Last reply
    0
    • P Peter Walburn

      Hi, I have a C# program that will start another external program (such as notepad). The C# program needs to pass arguments and the working directory to the external program. I have attempted to do this like: Process process = new Process(); try { process.StartInfo.UseShellExecute = false; process.StartInfo.FileName = @"c:\Windows\notepad.exe"; process.StartInfo.Arguments = @"c:\test.txt"; process.StartInfo.WorkingDirectory = @"c:\temp"; process.Start(); process.WaitForExit(); } catch { MessageBox.Show("Error running " + strExe, "Error", MessageBoxButtons.OK); } Notepad does start and opens the correct file, but the Working Directory has not been set. I have tried setting the current directory of the C# applicaiton, then running the notepad process, but the Working Directory is still not set. Please help! Pete

      B Offline
      B Offline
      benjymous
      wrote on last edited by
      #2

      How do you know this isn't working? How do you know what Notepad is receiving for its working directory? Its file open/save dialogs remember the last directory you used.

      Help me! I'm turning into a grapefruit! Buzzwords!

      P 1 Reply Last reply
      0
      • P Peter Walburn

        Hi, I have a C# program that will start another external program (such as notepad). The C# program needs to pass arguments and the working directory to the external program. I have attempted to do this like: Process process = new Process(); try { process.StartInfo.UseShellExecute = false; process.StartInfo.FileName = @"c:\Windows\notepad.exe"; process.StartInfo.Arguments = @"c:\test.txt"; process.StartInfo.WorkingDirectory = @"c:\temp"; process.Start(); process.WaitForExit(); } catch { MessageBox.Show("Error running " + strExe, "Error", MessageBoxButtons.OK); } Notepad does start and opens the correct file, but the Working Directory has not been set. I have tried setting the current directory of the C# applicaiton, then running the notepad process, but the Working Directory is still not set. Please help! Pete

        S Offline
        S Offline
        SeMartens
        wrote on last edited by
        #3

        How did you know that the WorkingDirectory was not set?

        It's not a bug, it's a feature! Check out my CodeProject article Permission-by-aspect. Me in Softwareland.

        P 1 Reply Last reply
        0
        • B benjymous

          How do you know this isn't working? How do you know what Notepad is receiving for its working directory? Its file open/save dialogs remember the last directory you used.

          Help me! I'm turning into a grapefruit! Buzzwords!

          P Offline
          P Offline
          Peter Walburn
          wrote on last edited by
          #4

          I've found out that it does work after all. I started a batch file that printed the current directory and ran this from the process and it did print the Working Directory!!! I've spent ages trying to get it working with Notepad and kept trying the File/Save As... to see if the folder was the Working Directory. I didn't realise that it was always the last one used. Pete

          1 Reply Last reply
          0
          • S SeMartens

            How did you know that the WorkingDirectory was not set?

            It's not a bug, it's a feature! Check out my CodeProject article Permission-by-aspect. Me in Softwareland.

            P Offline
            P Offline
            Peter Walburn
            wrote on last edited by
            #5

            I've found out that it does work after all. I started a batch file that printed the current directory and ran this from the process and it did print the Working Directory!!! I've spent ages trying to get it working with Notepad and kept trying the File/Save As... to see if the folder was the Working Directory. I didn't realise that it was always the last one used. Pete

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups