[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 219
  • Last Modified:

Shutdown NT through VB

Hi, how can I shutdown and turn off my
computer running NT or 2k through VB ??
thx m
0
MKrauss
Asked:
MKrauss
1 Solution
 
samic400Commented:
Check this out:

http://msdn.microsoft.com/library/psdk/sysmgmt/shutdown_3ago.htm

basic code will look like this:

Private Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long
Const EWX_LOGOFF = 0 ' parameter for log off
Const EWX_REBOOT = 2 ' parameter for reboot
Const EWX_SHUTDOWN = 1 ' parameter for shutdown

Call ExitWindowsEx(EWX_SHUTDOWN, 0) ' last parameter is reserved and it is always zero

hope it helps.....



0
 
Valliappan ANSenior Tech ConsultantCommented:
Is that to shutdown a local m/c running Windows NT/2k?
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
TimCotteeCommented:
http://www.btinternet.com/~vbadmincode/code/shutdown.zip

Is a sample project which shows how to shutdown a local or remote NT/2K machine.
0
 
MKraussAuthor Commented:
Hi guys, thanks very much for all
the samples, now I have a little problem with
turning off the PC, I'm wondering the PC at work
is turning off when i do a manual shutdown, on all the samples above the shutdown comes to the pont
"its save to shutdown" and I need to turn it off
manually. How do I modify that so that my PC turns of ?
Any Ideas ?
thx M.
0
 
TimCotteeCommented:
http://www.winguides.com/registry/display.php/251/

Shows how to make a registry setting change which will power off the machine after successful shutdown.
0
 
MKraussAuthor Commented:
Hi Tim,
that doesnt work either ? but a maual shutdown
turns the PC off not the vb samples. will
continiue trying.
0
 
niklausjCommented:
Theres one more Flag to ExitWindowsEx function
it's
const EWX_POWEROFF = &H8&
just 'or' it to EWX_SHUTDOWN
0
 
mpaul4uCommented:
Using API TEXTVIWER utility copy syntax of API
SENDmessage()pass paramater as WM_CLOSE
0
 
DanRollinsCommented:
Hi MKrauss,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will suggest to:

    Accept niklausj's comment(s) as an answer.

MKrauss, if you think your question was not answered at all or if you need help, you can simply post a new comment here.  Community Support moderators will follow up.

EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
0
 
Computer101Commented:
Comment from expert accepted as answer

Computer101
E-E Moderator
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now