In Windows (XP, at least and maybe more) you can run the shutdown
command from a command line (i.e. using System Exec).
This has proven useful for us in remote desktop sessions when you need
to force a reboot.
I've listed the arguments below.
Good luck,
Ben
Ben Zimmer
[EMAIL PROTECTED]
Software Developer
Meikle Automation
975 Bleams Road, Unit #5
Kitchener, ON N2E3Z5
Tel: (519)896-0800 x361
Fax: (519)896-0002
Y:\>shutdown /?
Usage: shutdown [-i | -l | -s | -r | -a] [-f] [-m \\computername] [-t
xx] [-c "c
omment"] [-d up:xx:yy]
No args Display this message (same as -?)
-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 war
ning
-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 le
ss than 256)
yy is the minor reason code (positive
integer le
ss than 65536)
Y:\>AdobeWeb.log
-----Original Message-----
From: Paul F. Sullivan [mailto:[EMAIL PROTECTED]
Sent: Tuesday, January 27, 2004 7:25 AM
To: Daniel Alejandro Moyano
Cc: [EMAIL PROTECTED]
Subject: Re: Close aplications.
Daniel,
You asked:
>How can I do to close an aplication in LabView and close windows and
>turn off PC.
My connection of snippets from this forum has this from a couple of
years ago:
>Subject: Late response on exiting Windows Programmatically
>From: <[EMAIL PROTECTED]>
>Date: Mon, 5 Mar 2001 11:03:27 +0100
>
>Sorry for my late response but today I finally caught up with 2
>weeks of info-labview.
>
>I've looked into this a couple of weeks ago since I wanted to run my
>built LabVIEW application as the shell and shutdown the computer when
>the program quits.
>
>To exit windows under win98 and WinMe you should call the ExitWindowsEx
>function in shell32.dll. You could use the rundll.exe program like
>this: rundll32.exe shell32.dll,SHExitWindowsEx n
>
>where n is one, or a combination of, the following numbers:
>0 - LOGOFF, 1 - SHUTDOWN, 2 - REBOOT, 4 - FORCE, 8 - POWEROFF
>
>I haven't tested it because I only have one Win95 machine here but I
>found it here:
>http://support.microsoft.com/support/kb/articles/Q234/2/16.ASP
>
>Under WindowsNT look at the MSDN reference:
>http://msdn.microsoft.com/library/default.asp?URL=/library/psdk/sysmgmt
>/shutdown_5q25.htm
>
>It says that you need shutdown rights before you are allowed to
>shutdown the system, otherwise you will just log off. To get these
>rights you have to request them, every user can get shutdown rights for
>the local machine but you need administrator rights on the remote
>machine to do a remote shutdown (a remote shutdown is where you tell
>another computer then the one you are currently working on to
>poweroff).
>
>To get the rights to shutdown for your program you need to do some
>C-programming, maybe you could also do everything from LabVIEW. What I
>did I copied the source code found here:
>http://msdn.microsoft.com/library/psdk/sysmgmt/shutdown_7z8u.htm
>
>and put into a CIN (with some modification so I could specify the kind
>of shutdown I wanted (logoff, Windows Exit or complete power off).
>
>Then to really power down (if your hardware supports it) you should
>make a change in your registry found here:
>http://msdn.microsoft.com/library/default.asp?URL=/library/winresource/
>dnwinnt/s8554.htm
>
>HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows
>NT\CurrentVersion\Winlogon\PowerdownAfterShutdown -> "1"
>
>or download a utility from your computer vendor which enables
>poweroff after windows exit.
>
>Alternatively you can also download/use the WinNT Resource kit where
>you will find the shutdown.exe utility which will request the proper
>rights for you and poweroff if you start it with: shutdown.exe 3
>/powerdown
>http://support.microsoft.com/support/kb/articles/Q186/5/57.ASP
>
>I've made a little VI which will check if you run the development
>environment in which case it will check if you have made some unsaved
>changes and if not exit only LabVIEW. If you are running the runtime
>environment it will try to power down the system depending on Win9X or
>WinNT method.
>
>I haven't tried it on every platform and also I know that if you try to
>powerdown on a system that does not support it it will reboot under
>Windows95 instead of show the "it is now safe to turn off your
>computer" screen. But that would require some extra work and it already
>serves my purpose on the Dell WinNT machines I use (using the dell
>system utilities v.13)
>
>If you're interested let me know.
>
>Remco.
Hope it helps some.
--
EnWirementally,
Paul F. Sullivan
----------------------------------------------------
SULLutions (781)769-6869
"when a single discipline is not enough"
visit http://www.SULLutions.com
----------------------------------------------------