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. Visual Basic
  4. Process creation error in Win 7

Process creation error in Win 7

Scheduled Pinned Locked Moved Visual Basic
csharpvisual-studiohelp
7 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.
  • G Offline
    G Offline
    Gagan 20
    wrote on last edited by
    #1

    Hi all... I wrote an application in VB.NET (VS 2008) to start a process and read its output error. The code is given below :

    Private Function getProcessOutput(ByVal processName As String, ByVal args As String, ByVal processPath As String)
    Dim output As String = ""
    Try
    Dim prc As Process = New Process 'Create object of Process.
    Dim prcInfo As New ProcessStartInfo 'Create object of ProcessStartInfo
    With prcInfo 'Set attributes to ProcessStartInfo object.
    .FileName = processName 'processname to start
    .Arguments = args 'filename is passed as argument
    .CreateNoWindow = True 'Make background process
    .UseShellExecute = False 'Set to false to redirect output/error.
    .RedirectStandardOutput = True 'Enable output redirection
    .RedirectStandardError = True 'Enable error redirection
    .WorkingDirectory = processPath 'working directory where process file is stored.
    End With
    prc.StartInfo = prcInfo
    prc.Start()

                    prc.BeginOutputReadLine()   'Start reading output in asynchronous way.
                    output = prc.StandardError.ReadToEnd()  'Read whole error.
                    prc.WaitForExit()   'wait for process to exit.
      Catch ex as Exception
            Msgbox(ex.message)
      End Try
    
        Return output       'Return output whether it is error or program output.
    End Function
    

    This function is working pretty well in Windows XP but when I am trying to run this code in Win 7, it throws an exception that file not found. I checked process name and working directory for the file which I want to run but still it is generating same error message. Suggest me what should I do. Thanks.

    Gagan

    L 1 Reply Last reply
    0
    • G Gagan 20

      Hi all... I wrote an application in VB.NET (VS 2008) to start a process and read its output error. The code is given below :

      Private Function getProcessOutput(ByVal processName As String, ByVal args As String, ByVal processPath As String)
      Dim output As String = ""
      Try
      Dim prc As Process = New Process 'Create object of Process.
      Dim prcInfo As New ProcessStartInfo 'Create object of ProcessStartInfo
      With prcInfo 'Set attributes to ProcessStartInfo object.
      .FileName = processName 'processname to start
      .Arguments = args 'filename is passed as argument
      .CreateNoWindow = True 'Make background process
      .UseShellExecute = False 'Set to false to redirect output/error.
      .RedirectStandardOutput = True 'Enable output redirection
      .RedirectStandardError = True 'Enable error redirection
      .WorkingDirectory = processPath 'working directory where process file is stored.
      End With
      prc.StartInfo = prcInfo
      prc.Start()

                      prc.BeginOutputReadLine()   'Start reading output in asynchronous way.
                      output = prc.StandardError.ReadToEnd()  'Read whole error.
                      prc.WaitForExit()   'wait for process to exit.
        Catch ex as Exception
              Msgbox(ex.message)
        End Try
      
          Return output       'Return output whether it is error or program output.
      End Function
      

      This function is working pretty well in Windows XP but when I am trying to run this code in Win 7, it throws an exception that file not found. I checked process name and working directory for the file which I want to run but still it is generating same error message. Suggest me what should I do. Thanks.

      Gagan

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      Gagan.20 wrote:

      it throws an exception that file not found.

      rather than showing some code (which looks OK), you should have shown the value of processName (is it a full path, a relative path? anything special, maybe one of the special folders?), and the entire exception (the ToString result, not just the Message). Anyway, if the system says "File Not Found" it means it can't find a file it needs. It could be the exe file you want to run, or one of its dependents. Look more closely. :)

      Luc Pattyn [My Articles] Nil Volentibus Arduum

      G 1 Reply Last reply
      0
      • L Luc Pattyn

        Gagan.20 wrote:

        it throws an exception that file not found.

        rather than showing some code (which looks OK), you should have shown the value of processName (is it a full path, a relative path? anything special, maybe one of the special folders?), and the entire exception (the ToString result, not just the Message). Anyway, if the system says "File Not Found" it means it can't find a file it needs. It could be the exe file you want to run, or one of its dependents. Look more closely. :)

        Luc Pattyn [My Articles] Nil Volentibus Arduum

        G Offline
        G Offline
        Gagan 20
        wrote on last edited by
        #3

        I am passing cmd.exe as process name and working directory as c:\Windows\System32\ The error message is : System.ComponentModel.Win32Exception: The system cannot find the file specified at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo) All the necessary files are present and same code is working in Win XP but not in Win 7. What to do to make this code running on Win 7? Thanks.

        Gagan

        L 1 Reply Last reply
        0
        • G Gagan 20

          I am passing cmd.exe as process name and working directory as c:\Windows\System32\ The error message is : System.ComponentModel.Win32Exception: The system cannot find the file specified at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo) All the necessary files are present and same code is working in Win XP but not in Win 7. What to do to make this code running on Win 7? Thanks.

          Gagan

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #4

          My best guess is you are having 32-bit/64-bit trouble. Here are some facts: - a process can't mix 32-bit and 64-bit code, it has to be homogeneous. - on 64-bit systems Task Manager appends a "*" on process names for processes running in 32-bit mode. - managed code exe's built for "64bit" or "AnyCPU" will run in 64-bit mode on a 64-bit system; managed code DLL files should be built in "AnyCPU" (the default), making them work everywhere. - Files get organized differently on 64-bit systems, 64-bit system code is stored in system32 (!!) and 32-bit code in the new sysWOW64 folder. The easiest approach often is: - build managed stuff for "x86" (i.e. make it execute in a 32-bit process); - store required DLLs in WOW64 when you put them in system32 on 32-bit systems. :)

          Luc Pattyn [My Articles] Nil Volentibus Arduum

          G D 2 Replies Last reply
          0
          • L Luc Pattyn

            My best guess is you are having 32-bit/64-bit trouble. Here are some facts: - a process can't mix 32-bit and 64-bit code, it has to be homogeneous. - on 64-bit systems Task Manager appends a "*" on process names for processes running in 32-bit mode. - managed code exe's built for "64bit" or "AnyCPU" will run in 64-bit mode on a 64-bit system; managed code DLL files should be built in "AnyCPU" (the default), making them work everywhere. - Files get organized differently on 64-bit systems, 64-bit system code is stored in system32 (!!) and 32-bit code in the new sysWOW64 folder. The easiest approach often is: - build managed stuff for "x86" (i.e. make it execute in a 32-bit process); - store required DLLs in WOW64 when you put them in system32 on 32-bit systems. :)

            Luc Pattyn [My Articles] Nil Volentibus Arduum

            G Offline
            G Offline
            Gagan 20
            wrote on last edited by
            #5

            Thanks Luc for your help. :) I compiled and run my code on 32-bit successfully. But if I want to run this code on 64-bit then what should I do? Thanks.

            Gagan

            1 Reply Last reply
            0
            • L Luc Pattyn

              My best guess is you are having 32-bit/64-bit trouble. Here are some facts: - a process can't mix 32-bit and 64-bit code, it has to be homogeneous. - on 64-bit systems Task Manager appends a "*" on process names for processes running in 32-bit mode. - managed code exe's built for "64bit" or "AnyCPU" will run in 64-bit mode on a 64-bit system; managed code DLL files should be built in "AnyCPU" (the default), making them work everywhere. - Files get organized differently on 64-bit systems, 64-bit system code is stored in system32 (!!) and 32-bit code in the new sysWOW64 folder. The easiest approach often is: - build managed stuff for "x86" (i.e. make it execute in a 32-bit process); - store required DLLs in WOW64 when you put them in system32 on 32-bit systems. :)

              Luc Pattyn [My Articles] Nil Volentibus Arduum

              D Offline
              D Offline
              DaveAuld
              wrote on last edited by
              #6

              Luc Pattyn wrote:

              640bit systems

              640 wow, where can i get one of those? what would the maximum addressable memory be?? :laugh:

              Dave Find Me On: Web|Facebook|Twitter|LinkedIn


              Folding Stats: Team CodeProject

              L 1 Reply Last reply
              0
              • D DaveAuld

                Luc Pattyn wrote:

                640bit systems

                640 wow, where can i get one of those? what would the maximum addressable memory be?? :laugh:

                Dave Find Me On: Web|Facebook|Twitter|LinkedIn


                Folding Stats: Team CodeProject

                L Offline
                L Offline
                Luc Pattyn
                wrote on last edited by
                #7

                DaveAuld wrote:

                640 wow, where can i get one of those?

                many places, wide stuff[^] has been researched and experimented with for decades.

                DaveAuld wrote:

                what would the maximum addressable memory be??

                gigantic wouldn't start to describe it. :)

                Luc Pattyn [My Articles] Nil Volentibus Arduum

                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