Can any one tell me if there is a code for VB to shutdown windows for example,
if i hit start an hit shutdown it shutsdown the computer, if there is a piece of code what is it.
im using VB 2003.net :wave:
Printable View
Can any one tell me if there is a code for VB to shutdown windows for example,
if i hit start an hit shutdown it shutsdown the computer, if there is a piece of code what is it.
im using VB 2003.net :wave:
Probably not the best, but use the process and issue the command "shutdown -s -t 00".
You can call Process.Start to execute the command PENNYSTOCK suggests, but it must be done with two parameters:The shutdown.exe commandline program can do much more than that too. You can get help on its parameters either in the Windows help or on the commandline itself. The other option is to use the ExitWindowsEx API. There are plenty of examples on the forum already. Keep in mind that while both these options will work on WinXP they are not available on all Windows versions. I believe that there's another API too but I can't remember the name. Something like "InitiateWindowsShutdown" but not quite.VB Code:
Process.Start("shutdown", "-s -t 00")
There is this too...An API. However, this just shows the shut down dialog screen.
Declare Function SHShutDownDialog Lib "shell32" Alias "#60" (ByVal YourGuess As Int32) As Int32
Then just call
VB Code:
SHShutDownDialog(1234)
That other API I mentioned is InitiateSystemShutdown and it is available on Win2003 and WinXP only. ExitWindowsEx is available back to Win95, so it is probably the safest bet if your app is likely to be used on older platforms. I believe that shutdown.exe may only be available from Win2000, but I'm not 100% sure.
ty for the feedback ill try ur suggestions