Windows XP Startup Scripts is a batch file that the computer runs before the login screen, which is similar to the automatic execution batch file autoexec.bat in Windows 9 × and DOS. With this feature, you can write a batch file to reset the user password and add it to the startup script so that the purpose is achieved. The following is a specific step (assuming the system directory is C: / Windows).
1. Use the Windows98 boot disk to launch your computer. Write a batch file A.BAT that can restore your password, you only need a "net user" command: "NET USER RWD 12345678". This command means setting the user RWD password to "12345678" (see Windows Help) about the use of NET commands). The file A.BAT is then saved to "C: / Windows / System32 / GroupPolicy / Machine / Scripts / Startup".
2. Write a start / shutdown script configuration file Scripts.ini, this file name is fixed, and cannot be changed. The content is as follows:
[Startup]
0cmdline = a.bat
0Parameters =
3. Save the file scripts.ini to "C: / Winnt / System32 / GroupPolicy / Machine / Scripts". Scripts.ini saves the setting data of the computer start / shutdown script, and the file content usually contains two data segments: [Startup] and [Shutdown]. The [startup] data segment is the startup script configuration, and it is a shutdown script configuration under the [shutdown] data segment. Each script entry is divided into feet name and script parameters two parts stores, the script name is saved under the XCMDline keyword, the parameters are saved under the XParameters keyword, the x represents the script serial number starting from 0 to distinguish multiple scripts and flags The order of operation of each script entry.
4. Remove the Windows 98 boot disk, restart your computer, wait for the startup script to run. After the startup script runs, the password of the user RWD is restored to "12345678".
5. After the login is successful, delete the two files established by the above steps.
Note: My computer uses the FAT32 file system. If you use the NTFS file system, you can use this hard drive to make the above operation on a computer that identifies NTFS file systems (such as Windows 2000 or Windows XP). . This method can restore the password of the administrator. The password recovery of local computer users and domain users in Windows2000 systems is equally valid.
Maybe it's worth a look.
Start / shutdown script
Deepen Shallow WIN2000 computer start / shutdown script
Introduction
Win2000 computer start / shutdown script (startup / shutdown scripts) is a new feature of Win2000. The startup script is a batch file that is invited to run before logging in, which is similar to the automatic execution batch file autoeexec.bat in Win9X and DOS; The shutdown script is a batch file running before the computer is turned off.
Compared with Win2000 User Log in / Log In, the main difference between them is: Computer start / shutdown scripts run when computer startup and shutdown, the script is only running once, usually after the startup script is completed. Only the invitation user login dialog; user login / logout script runs after inviting the user login, the user logs in to the system or runs from the system, and the number of runs is determined by the number of users log in / logout, each login / logout system Once, the script runs once.
II. Assignment
Before the computer start / shutdown script is enabled, it must be assigned. Assign computer start / shutdown scripts need to be performed by Group Policy MMC (Management Console) management unit, the specific operations are as follows:
1. Click the "Start" menu -> "Run", enter "MMC" in the open box, open the Microsoft Management Console, MMC .2. Click Console "Menu -> Add / Delete Management Unit ... ", click the Add / Delete Management Unit dialog box to add an independent management unit.
3. Select "Group Policy" in the "Available Independent Management Unit" list of "Add Independent Management Unit" dialog box, press the "Add" button below.
4. When the system is asked which group policy object is used, if you want to assign a local computer, start / shutdown on the local computer, select the default Local Computer group policy object; if you want to assign Win2000 domain, start / shutdown scripts on all computers in the domain, then click the "Browse ..." button in the "Select Group Policy Object" dialog box, select the "Browse Group Policy" dialog box to apply to the entire Group Policy Objects in the domain, here as an "Default Domain Policy" object, which is the Win2000 domain default domain policy object (Figure 1) (T1.GIF).
5. After the completion is completed, close the dialogs and return to the management console. Now there is a corresponding group policy object tree (Figure 2) (T2.GIF) on the management console.
6. In the console tree pane on the left side of the management console, expand Group Policy Objects -> "Computer Configuration" -> "Windows Settings" -> "Node (Start / Close)" node, double-click the right side detail The "Start" or "Shutdown" item in the pane can set the script used when the computer is started or turned off (T3.GIF) (T3.GIF) (Due to the same method as the Win2000 computer starts and the shutdown script, the following operations are all Take the startup script as an example).
7. Double-click the "Start" project in the detail pane on the right, click the "Add" button in the "Start Properties" dialog box to add a new computer startup script.
8. A startup script entry includes two aspects: script name and script parameters (Figure 4) (T4.GIF). If the script is not included, such as the script file name in the figure is just "scripta.vbs", system Looking for this script file in the default computer startup scripting path. The parameters of the script are optional, which can be filld, and the actual situation is determined, and the power-on script in the figure uses the running parameter "start".
9. The default path of the local computer script is usually "% systemroot% / system32 / grouppolicy / machine / scripts", such as "C: / WinNT / System32 / GroupPolicy / Machine / Scripts". Application to the default computer script The path is usually "" //
10. We can repeat the "Add" button in the "Start Properties" dialog box as needed, add multiple boot scripts (T5.GIF) to your computer.
11. After setting up, the group policy MMC management unit is exited after saving. When the Group Policy is refreshed, these scripts work when the computer is started and turned off.
Three in depth
1. We have saved the computer start / shutdown script by Win2000 in a hidden configuration file called Scripts.ini, this file is located in the "C: / WinNT / System32 / GroupPolicy / Machine / Scripts" directory, you can Editing software using any file, such as Notepad, such as Notepad. Scripts.ini file content usually contains two data segments: [startup] and [shutdown], [STARTUP] data segment is startup script configuration, [shutdown] data section It is a shutdown script configuration. Each script entry is divided into a footname and a script parameter two partial storage. The script name is saved under the xcmdline keyword, and the parameters are saved under the XParameters keyword. The x represents the script serial number starting from 0 to distinguish Multiple script entries and flags each script are running order. Below is an example of a simple scripts.ini file:
[Startup]
0cmdline = d: /start/ss.bat
0Parameters =
1cmdline = scriptsa.vbs
1Parameters = Start
[Shutdown]
0cmdline = shut.vbs
0Parameters =
From the example, we can see that two computers are set up: ss.bat and scripta.vbs.ss.bat are located in the D: / Start directory, no parameters; Scriptsa.vbs is located in the default startup script directory C: / Winnt / System32 / GroupPolicy / Machine / Scripts / Startup User Use the parameter "start". The execution order of the two scripts is to perform Scriptsa.vbs after SS.BAT. Set a shutdown script Shut.vbs, No parameters are used, the script is located in the default shutdown script directory C: / WinNT / System32 / GroupPolicy / Machine / Scripts / Shutdown.
2. Start / shutdown script, contain whether it is synchronously run, whether it is displayed, the longest waiting time, etc., can be fine-tuning in group policies. The specific operation is as follows:
(1) - (5) Step the second part assigning 1-5 steps in the operation;
(6) In the console tree pane on the left side of the management console, expand the Group Policy Object -> Computer Configuration -> "Administrative Template" -> "Login" node, the right side is displayed in the details pane. The content has four related to the start / shutdown script (Figure 6) (T6.gif): Non-synchronous running start scripts, display the running script of the startup script, display the running status of the shutdown script, the longest waiting time of the group policy script.
(7) Non-synchronous running start script
Under the default (that is, there is no configuration, the following), the system should wait for each startup script to run the next startup script. If this policy is enabled, the system will not coordinate the running order of the startup script, start the script You can run at the same time. If this policy is deactivated or not, each startup script is to run after the last script is running. It is recommended not to configure.
The registry value corresponding to this policy is "HKEY_LOCAL_MACHINE / SOFTWARE / Microsoft / Windows / CurrentVersion / Policies / System / RunstartupScriptsync", this is a REG_DWORD value, 0 indicates enabled, 1 indicates disabled.
(8) Display the running status of the start / shutdown script
By default, the system does not display instructions in the startup script. If this policy is enabled, the system will display each instruction when the script is started, and the instruction will appear in the command window, or display the interface of the interfacial interface. This feature is mainly designed for advanced users. If you deactivate or do not configure this policy, the instruction will not be displayed. It is recommended not to configure.
For example, assume that you have a command in the startup script is "c: /winnt/explorer.exe c: / winnt", if this policy allows this policy to display the running state of the startup script, then when the computer is started, one The resource manager window will jump, the desktop is opened, and the system logs in to the computer with the SYSTEM user, which is tantamount to the famous input method! This can be seen, open the start / shutdown script. Sometimes it is very dangerous.
The two group policy registry entries corresponding values are "HKEY_LOCAL_MACHINE / SOFTWARE / Microsoft / Windows / CurrentVersion / policies / system / HideStartupScripts" and "HKEY_LOCAL_MACHINE / SOFTWARE / Microsoft / Windows / CurrentVersion / policies / system / HideShutdownScripts", are For the REG_DWORD value, 0 means enabled, 1 indicates disabled. (9) Group policy script's longest waiting time
This policy limits all the time required to run login, start and turn off scripts by group policies. If the specified time has exceeded but the script has not been run, the system will stop the script processing and record an error event. By default, the system Allow the merged script set to run 600 seconds (10 minutes).
To use this policy, type the number between 1 and 32000 between the second box to determine the time you want the system to wait for the script, the unit is second. To allow the system to wait until the running script, no matter how long it takes time, Type 0 (Figure 7) (T7.gif). But do not recommend this, if your script is very bad, then the consequences will be unimaginable!
If other system tasks must wait for script to be done, this interval is very critical. In the default, each startup script must be completed, you can also use the "Non-Synchronous Running Start Script" policy to let the system When the startup script is completed, the invitation user login is invited to log in. The interval can delay the system and make the user inconvenient. If the interval is too short, the required task cannot complete the system prematurely, resulting in problems.
The registry value corresponding to this group policy entry is "HKEY_LOCAL_MACHINE / SOFTWARE / Microsoft / Windows / CurrentVersion / Policies / System / MaxGPoscriptWait", is also a REG_DWORD value, which represents the waiting time, the unit is second.
Application
There are many applications for computer boot / shutdown scripts, and the following is a relatively typical example:
1. Computer launch and shutdown time audit
(1) Write a script logtime.vbs that can record time, as follows:
'==================================================
DIM Argobj, Str, Strtmp
Set argobj = wscript.Arguments
IF argobj.count <1 THEN
Strtmp = "No parameters!"
Else
Select Case Argobj.Item (0)
Case "Startup"
StrtMP = "server start."
Case "shutdown"
Strtmp = "The server is turned off."
Case Else
Strtmp = "Unknown action! Parameters:" argobj.Item (0)
End SELECT
END IF
SET FSO = CreateObject ("scripting.filesystemObject")
Set tmp = fso.opentextfile ("d: /log/logtime.txt", 8, true)
Str = "[" CSTR (now ()) "]" strtmp chr (13) chr (10)
Tmp.Write Str
TMP.CLOSE
SET TMP = NothingSet FSO = Nothing
'====================================================
This script has two parameters: startup and shutdown. When used as a startup script, use the "startup" parameter; when using the shutdown script, use the "shutdown" parameter. In addition, the FileSystemObject object is used in the script, before using this script Make sure this object already exists on your computer.
(2) Set the script to set the script in the previous method. This script will run each time the computer is started or turned off, and the computer is started or turned off (actually at which the script is running, but the two should be different) records. In a text file, the example is "d: /log/logtime.txt", which can be changed as needed.
2. Delete some special sharing
In WIN2000, due to computer management, user login, etc., many special shares, such as C $, D $, Admin $, IPC $, Netlogon, etc., but these shares are not all computers. Use "Computer Management" MMC or NET Share command, etc., forbidden these shares, just a method of cursor, reappeared after the computer is restarted. For security, we sometimes want to completely delete these sharing Now remove this particular shared method, such as editing the registry, then provide a method of deleting these special sharing using the startup script.
(1) Write a batch file DELSHARE.BAT that can delete special sharing, as follows:
NET Share C $ / Delete
NET Share D $ / Delete
NET Share IPC $ / Delete
NET Share Netlogon / Delete
(2) Set the script to start the script in the previous method, restart your computer. OK, everything is clean.
3. Restore administrator passwords or new administrator accounts
Lost administrator password is a very headache thing, but maybe it will encounter. In emergency, how to restore administrator passwords and even create a new administrator account, now there are many mature technologies, such as classics Login screen saver, using O & O software, etc. In fact, the startup script is also a quite good choice.
(1) If the fault computer uses the FAT / FAT32 file system, you can use the WIN98 boot disk directly. If you use the NTFS file system, you can remove the hard drive on the failed computer to the disk mode to other Win2000 computers. The following operations are subject to the next case, assuming that the SYSTEM partition of the current faulty computer (usually C is a partition E: on a new computer.
(2) Write a batch file from the batch file that can restore administrator's password, and the content can only be a "Net User" command. As follows:
Net user administrator 12345678
Here we assume that the current administrator is administrator, restore its password to "12345678". Save the file admin.bat to "E: / WinNT / System32 / GroupPolicy / Machine / Scripts / Startup", that is, the fault computer Under "C: / WinNT / System32 / GroupPolicy / Machine / Scripts / Startup".
(3) Write a start / shutdown script configuration file Scripts.ini, this file name is fixed, cannot be changed. The content is as follows:
[Startup]
0cmdline = admin.bat
0Parameters =
Save the file Scripts.ini to "E: / WinNT / System32 / GroupPolicy / Machine / Scripts", that is, the original "C: / WinNT / System32 / GroupPolicy / Machine / Scripts" of the faulty computer. (4) Put the hard disk Restore the primary disc, then retract the original computer, restart, wait for the startup script to run. Start the script runs the password of the administrator Administrator is restored to "12345678".
(5) If you want to create a new administrator account, the content of the admin.bat file can be modified to:
NET User Admin 12345678 / Add
Net localgroup administrators admin / add
Such an administrator account named "admin" and password is "12345678".
This method can not only restore the local administrator password on the standalone server, but also the password of the Win2000 domain administrator.