Click to See Complete Forum and Search --> : Remote System Shut Down - Please someone gimme the answer
venkatraman_r
Nov 15th, 1999, 12:35 PM
Hi Friends,
I have been asking this doubt for the 10th time i suppose. I got some replied but that was not sufficient for me.
I am in an NT Environment and my computer name is W3. I need to shutdown the computer W5 from my systems i.e. from W3. This should be made possible without loading the client software on W5.
Please someone help me out. I am in the dead end of my project without this.
Thanx in advance..
Venkat.
Ishamel
Nov 15th, 1999, 05:01 PM
I've been after something similar too.
I have tried messing about with the InitiateSytemShutdown API, but I can't seem to get it working.
Maybe if someone could show us some sample code that will hopefully point us in the right direction.
Any help would be grately appreciated.
Serge
Nov 15th, 1999, 06:19 PM
InitiateSytemShutdown API works fine only on WinNT.
Regards,
------------------
Serge
Software Developer
Serge_Dymkov@vertexinc.com
Access8484@aol.com
ICQ#: 51055819 (http://www.icq.com/51055819)
Ishamel
Nov 15th, 1999, 06:34 PM
Serge,
Do you have some sample code for using the InitiateSystemShutdown API??
Thanks in advance.
venkatraman_r
Nov 15th, 1999, 07:00 PM
Hi Serge,
Pls. give us the codes. It would ne of great use..i am using NT.
Venkat.
Inhumanoid
Nov 15th, 1999, 07:07 PM
InitiateSystemShutdown
The InitiateSystemShutdown function initiates a shutdown and optional restart of the specified computer.
BOOL InitiateSystemShutdown( LPTSTR lpMachineName,
// address of name of computer to shut down
LPTSTR lpMessage,
// address of message to display in dialog box
DWORD dwTimeout,
// time to display dialog box
BOOL bForceAppsClosed,
// force applications with unsaved changes flag
BOOL bRebootAfterShutdown
// reboot flag
);
Parameters
lpMachineName
Points to the null-terminated string that specifies the network name of the computer to shut down. If lpMachineName is NULL or points to an empty string, the function shuts down the local computer.
lpMessage
Points to a null-terminated string that specifies a message to display in the shutdown dialog box. This parameter can be NULL if no message is required.
dwTimeout
Specifies the time (in seconds) that the dialog box should be displayed. While this dialog box is displayed, the shutdown can be stopped by the AbortSystemShutdown function.
If dwTimeout is not zero, InitiateSystemShutdown displays a dialog box on the specified computer. The dialog box displays the name of the user who called the function, displays the message specified by the lpMessage parameter, and prompts the user to log off. The dialog box beeps when it is created and remains on top of other windows in the system. The dialog box can be moved but not closed. A timer counts down the remaining time before a forced shutdown. If the user logs off, the system shuts down immediately. Otherwise, the computer is shut down when the timer expires.
If dwTimeout is zero, the computer shuts down without displaying the dialog box, and the shutdown cannot be stopped by AbortSystemShutdown.
bForceAppsClosed
Specifies whether applications with unsaved changes are to be forcibly closed. If this parameter is TRUE, such applications are closed. If this parameter is FALSE, a dialog box is displayed prompting the user to close the applications.
bRebootAfterShutdown
Specifies whether the computer is to restart immediately after shutting down. If this parameter is TRUE, the computer is to restart. If this parameter is FALSE, the system flushes all caches to disk, clears the screen, and displays a message indicating that it is safe to power down.
Return Values
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
Remarks
To shut down the local computer, the calling process must have the SE_SHUTDOWN_NAME privilege. To shut down a remote computer, the calling process must have the SE_REMOTE_SHUTDOWN_NAME privilege on the remote computer. By default, users can enable the SE_SHUTDOWN_NAME privilege on the computer they are logged onto, and administrators can enable the SE_REMOTE_SHUTDOWN_NAME privilege on remote computers.
Common failures include an invalid or inaccessible computer name or insufficient privilege.
Ishamel
Nov 15th, 1999, 07:13 PM
Cheers Inhumanoid - thats exactly what I was after.
Where did you get that info? Is there a file/web site that gives this sort of help using all API's???
Inhumanoid
Nov 15th, 1999, 07:21 PM
Don't no of any web site with all API's :)
smalig
Nov 15th, 1999, 07:23 PM
Try it:
------------
Private Declare Function InitiateSystemShutdown Lib "advapi32.dll" Alias "InitiateSystemShutdownA" (ByVal lpMachineName As String, lpMessage As String, dwTimeout As Long, bForceAppsClosed As Boolean, bRebootAfterShutdown As Boolean) As Boolean
Private Sub Command1_Click()
Dim x&
x = InitiateSystemShutdown("pc_name", "Shutdown...", 0, True, False)
End Sub
------------------
smalig
smalig@hotmail.com
smalig.tripod.com (http://smalig.tripod.com)
onerrorgoto
Nov 15th, 1999, 07:36 PM
Hi
MartinLiss("Marty") posted this site as answer to another topic about API,
I don't know if it kontain ALL API's but there is alot of them and you can download the entire site in a zip file if you want. http://skyscraper.fortunecity.com/transmission/45/api/index.html
------------------
******
on error goto bed ;0)
anders@zsystemdesign.se
*******
venkatraman_r
Nov 16th, 1999, 10:56 AM
Hi Guys,
Amazed to know that there are people around the world to help me out. Thanx all :) :) :)
Smalig - I tried ur code but did not work. The target machine stays idle and nothing happens. I have all the rights over other systems.
But anyway thanx for ur help.
Inhumanoid - Ur explanations are too good. Thanx.
Once again I thank u all my friends.
Venkat :) :) :)
Serge
Nov 16th, 1999, 06:10 PM
All this explanation came from MSDN. If you have VB6 then you should have it installed. If you don't have it installed then try the MSDN Library Online (http://msdn.microsoft.com/library/default.htm?MSCOMTB=ICP_lib|%20Library%20Home)
Regards,
------------------
Serge
Software Developer
Serge_Dymkov@vertexinc.com
Access8484@aol.com
ICQ#: 51055819 (http://www.icq.com/51055819)
[This message has been edited by Serge (edited 11-17-1999).]
Manish
Nov 17th, 1999, 01:15 PM
Hi
This code is fine when I need to shutdown a remote machine on Windows NT. any idea if i want to shutdown Windows 95/98 workstation????
Thanx Manish
Antonio Begue
Nov 17th, 1999, 10:33 PM
Use this to shutdown win 95 / 98
In a module:
Declare Function ExitWindowsEx Lib "user32" _
(ByVal uFlags As Long, ByVal dwReserved As Long) As Long
Public Const EWX_LOGOFF = &H0
Public Const EWX_SHUTDOWN = &H1
Public Const EWX_REBOOT = &H2
Public Const EWX_FORCE = &H4
In the form to call the function:
ExitWindowsEx EWX_LOGOFF, 0 'To log off
ExitWindowsEx EWX_REBOOT, 0 'To Reboot
ExitWindowsEx EWX_SHUTDOWN, 0 'To Shutdown
Manish
Nov 18th, 1999, 11:12 AM
I want to shutdown windows 95/98 workstations remotely from network server.
Wen Lie
Nov 18th, 1999, 12:27 PM
Dear All,
I've read all the message...
Now, continue on Manish question, I'd like to ask :
Can I shutdown a PC with Win 95/98, from my PC (also Win 95/98, not NT Station) ???
Thx...
Wille
Junior VB Programmer
Gazz
Nov 18th, 1999, 03:41 PM
I have been looking for a remote shutdown method for win 95/98 for a while now, and i've gotten used to the idea that the only way is to use a client-server program, as most people have told me. Personally, i believe that to gain the full effect from a true remote shutdown system, you should be able to use IP addresses and select a single/collection/or all PC's on a network.
Thinking about my initial question "Can i shut down remote computers WITHOUT a client server..." If possible, that would mean anybody could shut down anyone elses computer as long as they had their IP address (which are quite easily obtained).
If anyone wopuld like to see if they can find a way through this maze with me, e-mail me. I have code to obtain all network stations and their IP address. But i'm stuck on actually sending the shutdown command.
Stay Happy, e-mail me.
Gazz q:->
c98gj@whitchurch.cardiff.sch.uk
------------------
Don't let your fears stand in the way of your dreams.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.