Windows脚本编程核心技术精解Chapter14.pdf
《Windows脚本编程核心技术精解Chapter14.pdf》由会员分享,可在线阅读,更多相关《Windows脚本编程核心技术精解Chapter14.pdf(16页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、Chapter 14Getting Access to the RegistryIn This Chapter?Find out why the Registry is so important and how to back up its contents?Find out how the Registry organizes the internal Windows settings intodifferent branches?Use script commands to read and write to the Registry,and learn how tosafely exch
2、ange the registered owner information?Store your own values into the Registry and delete Registry information youno longer need?Enumerate entire Registry branches and list all entries hidden inside a keyThe Windows Registry is the ultimate place to control Windows at a very granular level.Learn how
3、to access and manipulate the Registry by script,and use a custom COM control to add Registry methods not foundin the standard WScript.Shellobject.Getting to Know the RegistryThe Registry is an incredible source of powerits here that Windows stores all its internal settings.You can control many Regis
4、try settingsthrough system dialog boxes,but many more Windows options are hidden and available only through direct Registry access.Lets take a look at the Registrys anatomy first.Then,Ill show you how toback up your Registry.Once you know the Registry better,its safe to usescripts to manipulate Regi
5、stry entries and create your own dialog boxes for any Windows option missing in the official dialog boxes.Where does the Registry live?The Registry actually is a database.Its merely data storage,and itsorganized differently for Windows 9.x and Windows NT/2000.4684-8 ch14.f.qc 3/3/00 9:39 AM Page 407
6、Registry on Windows 9.xOn Windows 9.x systems,the Registry consists of two filesUSER.DATandSYSTEM.DAT.They are stored in the Windows folder and marked as hidden.SYSTEM.DATcontains all common settings,and USER.DATcontains user-related information.If you have set up your Windows 9.x to support multipl
7、e user profiles,theRegistry still uses the central SYSTEM.DAT.For the user information,it usesindividual USER.DATfiles stored in the profiles subfolder.Registry on Windows NT/2000Windows NT/2000 organizes the Registry differently.Here,only users with Administrator or Power User membership have acces
8、s to the files.The common machine-related information is stored in the subfolderSYSTEM32CONFIGand consists of these files:DEFAULTSAMSECURITYSOFTWARESYSTEMThe user-related information is stored in a file called NTUSER.DAT.These files are stored individually in a subfolder called PROFILES/username/.Ac
9、cessing Registry contentYou dont need to care much about the physical location of your Registrydata.All Windows versions come with a special Registry Editor.Just chooseRunfrom your Start menu and enter REGEDIT.Dont change any Registry settings yet.The Registry Editor has direct access to the Registr
10、y,and any changes will be written to your“live”Registryimmediately,without a way to undo the changes.You may easily crash yourentire system or render it useless once you restart.The Registry Editor makes the Registry data visible and uses an Explorer-liketwo-pane view.In the left column,you see the
11、Registry keys.In the right pane,you see the actual data contained in the selected key.Table 14-1 shows how the Registry splits up information into a number of mainkeys,the“handles.”These handles and their subkeys act like file system folders and share thesame icon,too.View Registry keys as informati
12、on folders,and view the datain the right pane as information files.408Part IV:Accessing the Operating SystemII4684-8 ch14.f.qc 3/3/00 9:39 AM Page 408Table 14-1Main Windows Registry KeysMain KeyDescriptionHKEY_LOCAL_MACHINEHardware information and information that applies to allusers.HKEY_CURRENT_US
13、ERUser information for the currently logged-on user.It isactually a shortcut to HKEY_USERSusername.HKEY_USERSAccess to all user information(accesses all availableNTUSER.DAT).On Windows 9.x,you only see yourown user account.defaultrepresents the defaultuser account,which is used as long as nobody has
14、logged on.HKEY_CLASSES_ROOTShortcut to HKEY_CLASSES_ROOTSoftwareClasses.Contains information about registered filetypes and COM objects.HKEY_CURRENT_CONFIGMostly a shortcut into HKEY_LOCAL_MACHINESystemCurrent Control Set.HKEY_DYN_DATADynamic performance data only available on Windows 9.x.The right
15、pane splits information up into a name and a value.The namerepresents an entry while the value represents its content.To stick to the file system analogy,view the name as filename and the value as file content.Each key has at least one name entry:(Standard).Backing up the RegistryBefore you start ex
16、perimenting with the Registry,you should make sure to create a backup.Its your only safety net.If something goes wrong or you accidentally delete the wrong item,you can always restore your backup.Without a backup,you would be lost and would most likely need to reinstallyour complete system.Backing u
17、p the Registry is generally a good idea.Many Windows problemsoccur during software-or hardware-modification.With the help of a currentRegistry backup,you can undo those errors and revitalize your system in a matter of seconds.A Registry backup,therefore,is one of the mostimportant safeguards you can
18、 take advantage of.Backing up on Windows 95On your Windows CD,youll find the folder ERD.Copy it to your hard drive,then launch ERU.EXE.It will create a complete backup of important systemfiles,including the Registry.Dont use disks to store the backupthey aretoo small and wont save the Registry.Inste
19、ad,store the backup somewhereon your hard drive.Chapter 14:Getting Access to the Registry409II4684-8 ch14.f.qc 3/3/00 9:39 AM Page 409To restore the Registry,you must start your computer in DOS mode.Holddown F8 while Windows 95 starts and choose Command Prompt Only fromthe hidden boot menu.Then,navi
20、gate to the folder in which you stored yourbackup using the CD.You cant call your backup set from outside the backup folder.You need tochange the current directory to the backup directory.In your backup folder,call ERD Enter.The backup will be restored.Backing up on Windows 98Windows 98 automaticall
21、y backs up the Registry every day and maintains the last five copies.You can find them in the SYSBCKUPfolder inside yourWindows folder.To restore a backup,start your computer in DOS mode and call SCANREG/RESTORE.Windows checks the current Registry and then offers to restoreone of the five last backu
22、p sets.The Registry will constantly grow in size because deleted entries arent really deleted.They are just marked as“bad.”To re-create your Registry from scratch and discard any unused data,start your computer in DOS mode and use SCANREG/FIX.Backing up on Windows NTOn Windows NT,you can use the RDI
23、SK.EXEutility to create a rudimentaryemergency backup disk.It doesnt contain the complete Registry and willonly restore the most important keys.To create a full Registry backup,use the backup software provided withWindows NT.Make sure to select the option Backup Local Registry to include the Registr
24、y files.You must restore a Registry on the same system that you created the backup.Restoring it on a system with different hardware wont work.The easiest way to recover from Registry problems is the Last Known Goodconfiguration.If you select this option during boot time,Windows NT willautomatically
25、use the last Registry that worked without errors.Backing up on Windows 2000Windows 2000 comes with a sophisticated backup program.It allows you to back up files,folders,and the system-relevant parts.The system backupincludes the Registry.Windows 2000 also includes a Last Known Good configuration you
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- Windows 脚本 编程 核心技术 Chapter14
限制150内