Click here to Skip to main content
15,916,702 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi...

I want to run another exe when i click a button in my solution..

For this i am using Process.Start() Method..
It will work fine when i gave entire path..
ex: Process.Start("F://Honey//Second.exe");

But I without giving the path how i can execute or cal the Second Exe..

I tried
Process.Start("Second.exe");
        process.Start(Application.StartupPath + "//second.exe");

Both shows an error msg

Plz help me....


Regards
Honey.....
Posted
Updated 22-Nov-11 2:46am
v2
Comments
honey4bee 22-Nov-11 8:56am    
hi Rajesh...
i saw that link..
But my prob is not solved.....
LanFanNinja 22-Nov-11 9:33am    
Check solution

Starting a process with no path specified will use the standard Windows look up order, which is roughly speaking the current directory and then system folders and then the path environment variable. Note that the first lookup is the current directory, not the directory the assembly is in, though those two things are often the same.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 22-Nov-11 17:23pm    
In other words, using no path makes no sense. My 5. So far, this is the only relevant answer.
--SA
Read this Application Registration[^]

Without including the path Windows does not know where to find "second.exe". Also I recommend using "/" or "\\" as your path separator instead of "//" you could also prepend @ to the start of your path string like so: @"C:\Honey\second.exe".
Anyway in order for your app to be found without passing the path you will need to register it by either adding it to the system PATH environment variable or the App Paths registry key as show in the link.

Edit: If you copy the second EXE to the same path as the app you are creating the process from you would then be able to use Process.Start(Application.StartupPath + "\\Second.exe");
 
Share this answer
 
v3
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900