Click here to Skip to main content
15,896,486 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i create button on c# 2017 to run my application.exe
and that code :

Shell(Application.StartupPath & "\HTLauncher.exe -1")

Error :
the name 'shell' does not exist in the current context c#

and its work on c# 2010 what can i do ... please help

What I have tried:

Shell(Application.StartupPath & "\HTLauncher.exe -1");
Shell(Application.StartupPath & "\HTLauncher.exe")
Shell(Application.StartupPath & "\HTLauncher")
Posted
Updated 31-Dec-18 19:32pm

1 solution

See the Process class: Process Class (System.Diagnostics) | Microsoft Docs[^] and use the Process.Start method.
The link includes basic example code.
 
Share this answer
 
Comments
Ahmed Adel 1-Jan-19 2:07am    
that not help bro .. so shell not work in c# 2017.. thanks for your answer
OriginalGriff 1-Jan-19 2:22am    
Shell is a VB hangover to the old days of VB6 and before, it isn't available in C#, regardless of the versions of VS you are using. It's quite possible that your older code includes the definition of a method called Shell which does the same thing, but the .NET version uses the Process Class which is considerably more flexible.
Just follow the link and look at the example code.
Ahmed Adel 1-Jan-19 2:41am    
so i have to create bat file to run my application and let my program run my bat not bad idea for me :)
OriginalGriff 1-Jan-19 2:50am    
No. Did you follow the same link I did? Where in that do .BAT files even get mentioned?

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