How to remotely restart the NT Server with port 139

Source: Internet
Author: User
Tags net time

How to remotely restart the NT Server with port 139
Recently, many friends asked me: if the remote management software of the NT machine is broken, how can it be restarted? In fact, if port 139 of the server is on, it is very easy to restart. The steps are as follows:

1. net use // XXX. XXX/IPC $ password/User: Username
Create an IPC session

2. net use H: // XXX. XXX/C $
Map the disk C of the other party to your h disk.

3. Copy con h:/reboot. bat
Iisreset/reboot
CTRL + z
Generate a file on the drive C of the other party that can restart the computer.

4. NET Time // XXX. XXX
Obtain the Time of the peer.

5. At // XXX. XXX restart time C:/reboot. bat
The restart time is equal to the time of the other Party plus a few minutes.

6. At // XXX. XXX
Check whether the task has been added

7. Wait ......
The third step above is only for win2k. if NTIS used, you can compile a reboot.exe program to replace reboot. bat. The principle is very simple. The Code is as follows:
# Include "stdio. H"
# Include "windows. H"
Int main ()
{
// Define the messages sent to all users during the restart.
Lpstr MSG = "reboot tool by lion hook/nhttp: // www.xici.net ";
// Try to restart with the simplest API Function
If (exitwindowsex (ewx_reboot, 0) return true;
If (exitwindowsex (ewx_reboot ewx_force, 0) return true;
// Because the preceding restart fails, you need to adjust the privilege of this process.
Handle htoken;
Token_privileges tkp;
If (! Openprocesstoken (getcurrentprocess (), token_adjust_privileges token_query, & htoken) return false;
// Obtain the privilege se_shutdown_name
Lookupprivilegevalue (null, se_shutdown_name, & tkp. Privileges [0]. luid );
Tkp. privilegecount = 1;
Tkp. Privileges [0]. Attributes = se_privilege_enabled;
Adjusttokenprivileges (htoken, false, & tkp, 0, (ptoken_privileges) null, 0 );
// Determine whether the kernel is NT or 9x, and choose a different method
If (! (Getversion () & 0x80000000 ))
Initiatesystemshutdown (null, MSG, 20, true, true );
Else if (! Exitwindowsex (ewx_reboot, 0 ))
If (! Exitwindowsex (ewx_reboot ewx_force, 0 ))
Return false;
Return true;
}

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.