473,226 Members | 1,387 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,226 software developers and data experts.

Restart and Shutdown Windows XP - Visual Studio

Greetings to all ....

I have a need to issue a shutdown and/or Restart Windows XP inside my
application. Any help or example code would be appreciated!
--
Phil
Nov 6 '06 #1
5 17358
An easy way is just to call the Shutdown.exe command with the Process.Start
method, passing the desired switches:

Shutdown the computer

Syntax

SHUTDOWN [logoff_option] [/m \\Computer] [options]

logoff_option:
/i Display the GUI (must be the first option) /l Log
off. This cannot be used with /m or /d option /s Shutdown /r
Shutdown and Restart /a Abort a system shutdown.
(only during the time-out period)
/p Turn off the local computer with no time-out or warning
(only with /d) /h Hibernate the local computer (only with
/f ) /e Document the reason for an unexpected shutdown of a
computer

options:
/m \\Computer : A remote computer to shutdown.

/t:xxx : Time until system shutdown in seconds.
The valid range is xxx=0-600 seconds. [default=30]
/c "Msg" : An optional shutdown message [Max 127 chars]

/f : Force running applications to close.
This will not prompt for File-Save in any open
applications.
so will result in a loss of all unsaved data!!!

/d u:xx:yy : List a USER reason code for the shutdown.
/d P:xx:yy : List a PLANNED reason code for the shutdown.
xx Specifies the major reason code (0-255)
yy Specifies the minor reason code (0-65536)

-- Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Phil Tusa" wrote:
Greetings to all ....

I have a need to issue a shutdown and/or Restart Windows XP inside my
application. Any help or example code would be appreciated!
--
Phil
Nov 6 '06 #2
Thanks Peter for your very quick and helpful response!

--
Phil
>An easy way is just to call the Shutdown.exe command with the Process.Start
method, passing the desired switches:

Shutdown the computer

Syntax
Nov 6 '06 #3
Phil Tusa wrote:
Greetings to all ....

I have a need to issue a shutdown and/or Restart Windows XP inside my
application. Any help or example code would be appreciated!
--
Phil
System.Diagnostics.Process.Start("shutdown -f -s -t 0");

I think this should solve your problem
Nov 7 '06 #4
Phil Tusa <pt***@houston.rr.comwrites:
Greetings to all ....

I have a need to issue a shutdown and/or Restart Windows XP inside my
application. Any help or example code would be appreciated!
Besides the solutions mentioned by the others, if you do not want to
spawn another process, have a look at the ExitWindowsEx Win32-API
function[1] (user32.dll).

Best regards,
Martin

[1] http://pinvoke.net/default.aspx/user...WindowsEx.html
Nov 7 '06 #5
Thanks to everyone for your helpful assistance!

--
Phil
>
I have a need to issue a shutdown and/or Restart Windows XP inside my
application. Any help or example code would be appreciated!
Nov 7 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Eric Maino | last post by:
Setup Windows 2003 Server - Patched and up to date IIS 6.0 Front Page Server Extensions Installed Windows SharePoint Services Installed Visual Studio 2003 EA Web Sites Microsoft SharePoint...
3
by: Senthil | last post by:
Hi, I would like to know the code for reboot and shutdown windows xp professional using VB.Net. thanx Senthil
8
by: Glenn Lerner | last post by:
When I used Visual Studio 6 I was able to cascade source code windows. This allowed me to view 2 separate source code files side by side and copy and paste between windows. How do I do this in...
3
by: Treasure Baloyi | last post by:
I am an intermediate visual basic.Net programmer and want to know how to write the code to shutdown windows, irrespective of the version. Your assistance in this regard will be utmost...
11
by: Rolf Welskes | last post by:
Hello, the problem seems to be complex and is in all developments of web-controls which uses own TypeConverter. For this I have here a simple demo-program of the problem: The Control-code: A...
0
by: marathoner | last post by:
I am currently migrating my Visual C++ 6.0 applications to Visual Studio 2005. I am getting compiler errors involving the VS2005's platform SDK. When I removed directory references to that SDK,...
1
by: JSha | last post by:
Hello, I am using the following code to restart a Windows 2003 server system locally 1) I am setting the appropriate priviledge for the process by calling the SetCurrentProcessPrivileges with...
3
by: IdleBrain | last post by:
Gurus, I am trying to delay Windows Shutdown/Restart to perfrom cleanup and I am using the following code: protected override void WndProc(ref Message ex)
0
jwwicks
by: jwwicks | last post by:
Introduction This tutorial describes how to use Visual Studio to create a new C++ program, compile/run a program, resume work on an existing program and debug a program. It is aimed at the...
1
RRick
by: RRick | last post by:
I have a unix C++ project that needs to be converted over to windows visual studio. I'm not sure of the exact version of VS, but it's a recent version, probabIy 2003 or 2005. I would like the...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.