Click here to Skip to main content
15,885,546 members
Home / Discussions / C#
   

C#

 
AnswerRe: Running an exe file ( I mean a program) from inside my own program Pin
PIEBALDconsult14-Jan-11 1:46
mvePIEBALDconsult14-Jan-11 1:46 
AnswerRe: Running an exe file ( I mean a program) from inside my own program PinPopular
Luc Pattyn14-Jan-11 1:48
sitebuilderLuc Pattyn14-Jan-11 1:48 
GeneralRe: Running an exe file ( I mean a program) from inside my own program Pin
Fred 3414-Jan-11 2:00
Fred 3414-Jan-11 2:00 
GeneralRe: Running an exe file ( I mean a program) from inside my own program Pin
Dave Kreskowiak14-Jan-11 4:07
mveDave Kreskowiak14-Jan-11 4:07 
AnswerRe: Running an exe file ( I mean a program) from inside my own program PinPopular
JF201514-Jan-11 2:00
JF201514-Jan-11 2:00 
QuestionWhich is the best way to shutdown, reboot, or logoff from the system in C# (.NEt 4.0)? Pin
Erik14-Jan-11 0:16
Erik14-Jan-11 0:16 
AnswerRe: Which is the best way to shutdown, reboot, or logoff from the system in C# (.NEt 4.0)? Pin
Luc Pattyn14-Jan-11 0:33
sitebuilderLuc Pattyn14-Jan-11 0:33 
AnswerRe: Which is the best way to shutdown, reboot, or logoff from the system in C# (.NEt 4.0)? Pin
Ravi Sant14-Jan-11 1:50
Ravi Sant14-Jan-11 1:50 
The un-managed code is not recommended one in long term, although it is faster way to achieve same.

With managed, good way is:

using System.Diagnostics;

ProcessStartInfo startinfo = new ProcessStartInfo("shutdown.exe","-r");

Process.Start(startinfo);



Keep in mind the options you want to use:


-i Display GUI interface, must be the first option

-l Log off (cannot be used with -m option)

-s Shutdown the computer

-r Shutdown and restart the computer

-a Abort a system shutdown

-m \\computername Remote computer to shutdown/restart/abort

-t xx Set timeout for shutdown to xx seconds

-c "comment" Shutdown comment (maximum of 127 characters)

-f Forces running applications to close without warning

-d [u][p]:xx:yy The reason code for the shutdown, u is the user code, p is a planned shutdown code, xx is the major reason code (positive integer less than 256)
,yy is the minor reason code (positive integer less than 65536)
GeneralRe: Which is the best way to shutdown, reboot, or logoff from the system in C# (.NEt 4.0)? Pin
Dave Kreskowiak14-Jan-11 4:01
mveDave Kreskowiak14-Jan-11 4:01 
GeneralRe: Which is the best way to shutdown, reboot, or logoff from the system in C# (.NEt 4.0)? Pin
jschell14-Jan-11 9:58
jschell14-Jan-11 9:58 
AnswerRe: Which is the best way to shutdown, reboot, or logoff from the system in C# (.NEt 4.0)? Pin
Dave Kreskowiak14-Jan-11 4:05
mveDave Kreskowiak14-Jan-11 4:05 
QuestionGetting network drives names issue Pin
Priya Prk13-Jan-11 21:34
Priya Prk13-Jan-11 21:34 
AnswerRe: Getting network drives names issue Pin
RaviRanjanKr13-Jan-11 22:24
professionalRaviRanjanKr13-Jan-11 22:24 
GeneralRe: Getting network drives names issue Pin
OriginalGriff13-Jan-11 22:41
mveOriginalGriff13-Jan-11 22:41 
GeneralRe: Getting network drives names issue Pin
Priya Prk13-Jan-11 23:07
Priya Prk13-Jan-11 23:07 
AnswerRe: Getting network drives names issue Pin
Goutam Patra13-Jan-11 23:04
professionalGoutam Patra13-Jan-11 23:04 
GeneralRe: Getting network drives names issue Pin
Priya Prk13-Jan-11 23:09
Priya Prk13-Jan-11 23:09 
GeneralRe: Getting network drives names issue Pin
RaviRanjanKr13-Jan-11 23:14
professionalRaviRanjanKr13-Jan-11 23:14 
GeneralRe: Getting network drives names issue Pin
Goutam Patra13-Jan-11 23:25
professionalGoutam Patra13-Jan-11 23:25 
AnswerRe: Getting network drives names issue Pin
Pete O'Hanlon13-Jan-11 23:21
mvePete O'Hanlon13-Jan-11 23:21 
GeneralRe: Getting network drives names issue Pin
Priya Prk13-Jan-11 23:32
Priya Prk13-Jan-11 23:32 
AnswerRe: Getting network drives names issue Pin
Luc Pattyn14-Jan-11 1:41
sitebuilderLuc Pattyn14-Jan-11 1:41 
GeneralRe: Getting network drives names issue Pin
Priya Prk14-Jan-11 2:01
Priya Prk14-Jan-11 2:01 
GeneralRe: Getting network drives names issue Pin
Dave Kreskowiak14-Jan-11 4:00
mveDave Kreskowiak14-Jan-11 4:00 
AnswerRe: Getting network drives names issue Pin
jschell14-Jan-11 10:04
jschell14-Jan-11 10:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.