Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Shutdown NT through VB

Posted on 2001-06-10
11
196 Views
Last Modified: 2010-05-02
Hi, how can I shutdown and turn off my
computer running NT or 2k through VB ??
thx m
0
Comment
Question by:MKrauss
11 Comments
 
LVL 13

Expert Comment

by:samic400
ID: 6174096
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
 
LVL 33

Expert Comment

by:hongjun
ID: 6174662
0
 
LVL 9

Expert Comment

by:Valliappan AN
ID: 6175823
Is that to shutdown a local m/c running Windows NT/2k?
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
LVL 43

Expert Comment

by:TimCottee
ID: 6176342
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
 
LVL 1

Author Comment

by:MKrauss
ID: 6176683
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
 
LVL 43

Expert Comment

by:TimCottee
ID: 6176788
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
 
LVL 1

Author Comment

by:MKrauss
ID: 6177898
Hi Tim,
that doesnt work either ? but a maual shutdown
turns the PC off not the vb samples. will
continiue trying.
0
 
LVL 2

Accepted Solution

by:
niklausj earned 100 total points
ID: 6179032
Theres one more Flag to ExitWindowsEx function
it's
const EWX_POWEROFF = &H8&
just 'or' it to EWX_SHUTDOWN
0
 

Expert Comment

by:mpaul4u
ID: 6201596
Using API TEXTVIWER utility copy syntax of API
SENDmessage()pass paramater as WM_CLOSE
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7135846
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
 
LVL 1

Expert Comment

by:Computer101
ID: 7168357
Comment from expert accepted as answer

Computer101
E-E Moderator
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Determine Range to Select 5 52
How to debug this code 7 64
Problem to With line 4 63
Problem to line 23 53
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question