Process creation error in Win 7
-
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
-
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
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
-
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
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
-
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
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 newsysWOW64
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
-
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 newsysWOW64
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
-
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 newsysWOW64
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
-
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
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