Results 1 to 17 of 17

Thread: Remote System Shut Down - Please someone gimme the answer

  1. #1

    Thread Starter
    Hyperactive Member venkatraman_r's Avatar
    Join Date
    Jul 1999
    Location
    Chennai, INDIA
    Posts
    284

    Post

    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.



  2. #2
    Lively Member Ishamel's Avatar
    Join Date
    Nov 1999
    Location
    Edinburgh, Scotland
    Posts
    112

    Post

    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.

  3. #3
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Post

    InitiateSytemShutdown API works fine only on WinNT.


    Regards,

    ------------------

    Serge

    Software Developer
    Serge_Dymkov@vertexinc.com
    Access8484@aol.com
    ICQ#: 51055819


  4. #4
    Lively Member Ishamel's Avatar
    Join Date
    Nov 1999
    Location
    Edinburgh, Scotland
    Posts
    112

    Post

    Serge,

    Do you have some sample code for using the InitiateSystemShutdown API??

    Thanks in advance.

  5. #5

    Thread Starter
    Hyperactive Member venkatraman_r's Avatar
    Join Date
    Jul 1999
    Location
    Chennai, INDIA
    Posts
    284

    Post

    Hi Serge,

    Pls. give us the codes. It would ne of great use..i am using NT.

    Venkat.

  6. #6
    Hyperactive Member
    Join Date
    Oct 1999
    Posts
    309

    Post

    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.


  7. #7
    Lively Member Ishamel's Avatar
    Join Date
    Nov 1999
    Location
    Edinburgh, Scotland
    Posts
    112

    Post

    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???

  8. #8
    Hyperactive Member
    Join Date
    Oct 1999
    Posts
    309

    Post

    Don't no of any web site with all API's

  9. #9
    Addicted Member
    Join Date
    Oct 1999
    Posts
    232

    Post

    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

  10. #10
    Hyperactive Member onerrorgoto's Avatar
    Join Date
    Aug 1999
    Location
    Sweden
    Posts
    330

    Post

    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/tr...api/index.html

    ------------------
    ******
    on error goto bed ;0)
    anders@zsystemdesign.se
    *******


  11. #11

    Thread Starter
    Hyperactive Member venkatraman_r's Avatar
    Join Date
    Jul 1999
    Location
    Chennai, INDIA
    Posts
    284

    Post

    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

  12. #12
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Post

    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


    Regards,

    ------------------

    Serge

    Software Developer
    Serge_Dymkov@vertexinc.com
    Access8484@aol.com
    ICQ#: 51055819



    [This message has been edited by Serge (edited 11-17-1999).]

  13. #13
    Lively Member
    Join Date
    Apr 1999
    Location
    India
    Posts
    73

    Post

    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

  14. #14
    Lively Member
    Join Date
    Sep 1999
    Location
    Guayaquil, Guayas, Ecuador
    Posts
    87

    Post

    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

  15. #15
    Lively Member
    Join Date
    Apr 1999
    Location
    India
    Posts
    73

    Post

    I want to shutdown windows 95/98 workstations remotely from network server.

  16. #16
    Fanatic Member Wen Lie's Avatar
    Join Date
    Jul 1999
    Location
    Singapore
    Posts
    524

    Post

    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

  17. #17
    New Member
    Join Date
    Sep 1999
    Location
    Cardiff, Wales, United Kingdom
    Posts
    6

    Post

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width