- Сообщения
- 3,557
- Репутация
- 628
AutoIt: ?
Версия: 0.2b
Категория: Реестр
Описание: Утилита для управления реестром
Код: Пример
Файл: скачать
Снимок: N/A
История версий:
Источник: ?
Автор(ы): Jeremy Mlazovsky
Добавлено:
запускал скрипт на работе - работает отлично. (как раз был случай-нужно было переписать значения в реестре мертвой системы). запускал из-под Windows XP SP3.
сегодня запустил его дома. система та же (сам устанавливал и на работе и дома). выкидывает ошибку :
Версия: 0.2b
Категория: Реестр
Описание: Утилита для управления реестром
Код: Пример
Код:
#comments-start
*********************************************************************************************
Registry Editor PE was created by Jeremy Mlazovsky.
The SourceForge site for this project is at https://sourceforge.net/projects/regeditpe/
Installation Notes:
Copy the .ZIP file to your Plugins folder for Bart's PE Builder, and extract the contents.
It should create the correct plugin folder automatically.
Run Bart's PE Builder and make sure that the plugin is enabled before creating the .ISO.
This source code is released under the GNU GENERAL PUBLIC LICENSE. By using this code you
agree to be bound by this license.
The text of this license can be found here:
http://www.gnu.org/licenses/gpl.txt
*********************************************************************************************
#comments-end
Dim $temp
Dim $profilesdirectory
Dim $listofprofiledrives[257]
Dim $listofprofiledirs[257]
Dim $listofprofilenames[257]
Dim $listoffixeddrives[27]
Dim $WinPEDrive
Dim $listofremoteWinDirs[27] ;list of all possible Windows directories found
Dim $theremotewindir
Dim $thedrive ;The drive which has a copy of Windows to be editied
Dim $percent = 0 ;percent complete - starts at 0%
Dim $progresstitle = 'Registry Editor PE v0.2b' ;test in progress bar title
DIM $progressmaintext = '' ;main text in progress bar window
Dim $progresssubtext = '% Completed' ;subtext in progress bar window
$listofprofiledrives[0] = 0
;Unnecessary splash screen good for boosting my ego
SplashTextOn ( '', @CRLF & $progresstitle & @CRLF & 'Written by Jeremy Mlazovsky' & @CRLF & 'Copyright 2004' & @CRLF & @CRLF & 'https://sourceforge.net/projects/regeditpe/', 350, 130, -1, -1, 5, '', 14 )
Sleep ( 4500 )
SplashOff ( )
$percent = 0
$progressmaintext = 'Starting Registry Editor PE ... '
ProgressOn ( $progresstitle, $progressmaintext, $percent & $progresssubtext, -1 , 100, 0 ) ;set progress bar to 0% complete
Sleep ( 1500 )
;enumerate all fixed drives
$percent = 5
$progressmaintext = 'Enumerating all fixed drives ... '
ProgressSet ( $percent, $percent & $progresssubtext, $progressmaintext ) ;update progress bar
$listoffixeddrives = DriveGetDrive ( 'FIXED' )
Sleep ( 1500 )
;Abort if no fixed drives are present
If $listoffixeddrives[0] = 0 Then
ProgressOff ( )
MsgBox ( 0, 'Uh oh!', 'No fixed drives were found!' & @CRLF & 'No work to do!' )
Exit(1)
EndIf
;Determine the drive used by the Windows PE disk
$percent = 10
getWinPEDrive ( )
;Determine the folder name of the Windows directory on the fixed drive(s)
$percent = 15
getRemoteWinDir ( )
;Check if more than one copy of NT/2k/XP/2003 was found
;If more than one valid install exists, make user decide which one to use
$percent = 20
$progressmaintext = 'Looking for copies of Windows ... '
ProgressSet ( $percent, $percent & $progresssubtext, $progressmaintext ) ;update progress bar
If $listofremoteWinDirs[0] > 1 Then
getTheRemoteWinDirFromUser ( )
EndIf
Sleep ( 1500 )
;Try to load remote SAM hive
$percent = 30
loadSAM ( )
;Try to load remote SECURITY hive
$percent = 40
loadSecurity ( )
;Try to load remote SOFTWARE hive
$percent = 50
loadSoftware ( )
;Try to load remote SYSTEM hive
$percent = 60
loadSystem ( )
;Determine which drives could potentially include user profiles on them
$percent = 70
getProfileDrives ( )
;Ask user which remote profile to load
$percent = 80
getProfileList ( )
;Load the remote profile(s)
$percent = 85
loadProfiles ( )
;Run RegEdit
$percent = 95
$progressmaintext = 'Loading RegEdit ...'
ProgressSet ( $percent, $percent & $progresssubtext, $progressmaintext ) ;update progress bar
Sleep ( 1500 )
Run ( 'regedit.exe' )
;Wait for Registry editor window to appear
ProcessWait ( 'regedit.exe' )
$percent = 100
$progressmaintext = 'RegEdit loaded!'
ProgressSet ( $percent, $percent & $progresssubtext, $progressmaintext ) ;update progress bar
Sleep ( 1500 )
;Temporarily turn off progress indicator while regedit is running
ProgressOff ( )
SplashTextOn ( $progresstitle, 'Look in HKEY_LOCAL_MACHINE and' & @CRLF & 'HKEY_USERS for the remote registry hives.' & @CRLF & 'Close RegEdit when you are finished.', 400, 100 )
Sleep ( 7500 )
SplashOff ( )
;Wait until registry editor is closed
;WinWaitClose ( 'Registry Editor' )
ProcessWaitClose ( 'regedit.exe' )
;Do all of the cleanup stuff like unloading hives
$percent = 0
$progressmaintext = 'Running Registry Editor PE clean up ... '
ProgressOn ( $progresstitle, $progressmaintext, $percent & $progresssubtext, -1 , 100, 0 ) ;set progress bar to 0% complete
Sleep ( 1500 )
;Unload remote SAM hive
$percent = 10
unloadSAM ( )
;Unload remote SECURITY hive
$percent = 30
unloadSecurity ( )
;Unload remote SOFTWARE hive
$percent = 50
unloadSoftware ( )
;Unload remote SYSTEM hive
$percent = 60
unloadSystem ( )
;Unload user profiles
$percent = 80
unloadUserProfiles ( )
;All done!
$percent = 100
$progressmaintext = 'All finished!'
ProgressSet ( $percent, $percent & $progresssubtext, $progressmaintext ) ;update progress bar
Sleep ( 2500 )
Exit
;*******************************************
;*******************************************
Func getWinPEDrive ( )
$progressmaintext = 'Determining WinPE''s drive letter ... '
ProgressSet ( $percent, $percent & $progresssubtext, $progressmaintext ) ;update progress bar
$WinPEDrive = EnvGet ( 'SystemDrive' )
Sleep ( 1500 )
$progressmaintext = 'WinPE found at ' & $WinPEDrive & ' ...'
ProgressSet ( $percent, $percent & $progresssubtext, $progressmaintext ) ;update progress bar
Sleep ( 1500 )
EndFunc
;*******************************************
;*******************************************
Func getRemoteWinDir ( )
$progressmaintext = 'Determining remote WinDir(s) ... '
ProgressSet ( $percent, $percent & $progresssubtext, $progressmaintext ) ;update progress bar
;Go through each fixed drive looking for evidence of a Windows install
for $i = 1 to $listoffixeddrives[0]
;If fixed disk does not have WinPE on it, then continue
If $listoffixeddrives[$i] <> $WinPEDrive Then
;Look for NT/2k/XP/2003 install
;Win9x/ME not supported
;Look to see if <Drive letter>:\boot.ini exists
If FileExists ( $listoffixeddrives[$i] & '\boot.ini' ) = 1 Then
;Determine the WinDir from Boot.ini
;Assumes that the default OS is Windows
$tempwindir = IniRead ( $listoffixeddrives[$i] & '\boot.ini', 'boot loader', 'default', 'NotFound' )
$slashatchar = StringInStr ( $tempwindir, '\' ) ;Find the '\' which implies Windows directory name
$tempwindir = StringTrimLeft ( $tempwindir , $slashatchar ) ;strip off extra crap before and including '\'
;Bump up the count of the total copies of Windows found
$listofremoteWinDirs[0] = $listofremoteWinDirs[0] + 1
;Store the path name of the remote windir in the array
$listofremoteWinDirs[ $listofremoteWinDirs[0] ] = $listoffixeddrives[$i] & '\' & $tempwindir
EndIf
EndIf
Next
;If no remote installs of Windows could be found, just give up!
If $listofremoteWinDirs[0] = 0 Then
ProgressOff ( )
MsgBox ( 0, 'Uh oh!', 'Could not find a copy of Windows!' & @CRLF & 'No work to do!' )
Exit(1)
;If only one copy of Windows was found, then store the name in a variable for use later
ElseIf $listofremoteWinDirs[0] = 1 Then
;Take the first character of the path (which is the drive letter) and store its value
$thedrive = StringLeft ( $listofremoteWinDirs[1], 1 )
$thedrive = StringUpper ( $thedrive )
$theremotewindir = $listofremoteWinDirs[1]
;If more than one remote WinDir was found
ElseIf $listofremoteWinDirs[0] > 1 Then
getTheRemoteWinDirFromUser ( )
EndIf
Sleep ( 1500 )
EndFunc
;*******************************************
;*******************************************
Func getTheRemoteWinDirFromUser ( )
;Create string with list of remote WinDirs on it
;If only two remote WinDirs exist, then do the following:
If $listofremoteWinDirs[0] = 2 Then
$tempwindirlist = $listofremoteWinDirs[1] & ' and ' & $listofremoteWinDirs[2]
Else ;More than two WinDirs exist
$tempwindirlist = ''
;Create the list
for $i = 1 to ($listofremoteWinDirs[0] - 1)
$tempwindirlist = $tempwindirlist & ', ' @CRLF & $listofremoteWinDirs[$i]
Next
;Add to the list the final one
$tempwindirlist = $tempwindirlist & ', ' & @CRLF & 'and ' & @CRLF & $listofremoteWinDirs[ $listofremoteWinDirs[0] ]
EndIf
;Continue prompting user until a valid answer is given
Do
;Now that the list of WinDirs has been stored in a string, present the choices to the user
;and ask which one to use
$prompt = 'The following list of Windows directories was found: ' & @CRLF & $tempwindirlist & @CRLF & @CRLF & 'Which one do you wish to load?'
$userinput = InputBox ( $progresstitle, $prompt ) ;get input from the user
$validchoice = 'False' ;Assume user cannot type correctly
for $i = 1 to $listofremoteWinDirs[0]
;If user's answer matches one of the values in the list of remote WinDirs ...
If $userinput = $listofremoteWinDirs[$i] Then
$validchoice = 'True' ;Success!
$theremotewindir = $listofremoteWinDirs[$i]
EndIf
Next
Until $validchoice = 'True'
;Take the first character of the path (which is the drive letter) and store its value
$thedrive = StringLeft ( $userinput, 1 )
$thedrive = StringUpper ( $thedrive )
EndFunc
;*******************************************
;*******************************************
Func loadSAM ( )
$progressmaintext = 'Loading HKLM\SAM_ON_' & $thedrive & ' ...'
ProgressSet ( $percent, $percent & $progresssubtext, $progressmaintext ) ;update progress bar
If FileExists ( $theremotewindir & '\system32\config\sam' ) = 1 Then
RunWait( 'reg.exe LOAD HKLM\SAM_ON_' & $thedrive & ' ' & $theremotewindir & '\system32\config\sam', '', @SW_HIDE )
Sleep ( 1500 )
Else
ProgressOff ( )
MsgBox ( 0, 'No SAM!', $theremotewindir & '\system32\config\sam does not exist!' )
EndIf
EndFunc
;*******************************************
;*******************************************
Func loadSecurity ( )
$progressmaintext = 'Loading HKLM\SECURITY_ON_' & $thedrive & ' ...'
ProgressSet ( $percent, $percent & $progresssubtext, $progressmaintext ) ;update progress bar
If FileExists ( $theremotewindir & '\system32\config\security' ) = 1 Then
RunWait( 'reg.exe LOAD HKLM\SECURITY_ON_' & $thedrive & ' ' & $theremotewindir & '\system32\config\security', '', @SW_HIDE )
Sleep ( 1500 )
Else
ProgressOff ( )
MsgBox ( 0, 'No Security!', $theremotewindir & '\system32\config\security does not exist!' )
EndIf
EndFunc
;*******************************************
;*******************************************
Func loadSoftware ( )
$progressmaintext = 'Loading HKLM\SOFTWARE_ON_' & $thedrive & ' ...'
ProgressSet ( $percent, $percent & $progresssubtext, $progressmaintext ) ;update progress bar
If FileExists ( $theremotewindir & '\system32\config\software' ) = 1 Then
RunWait( 'reg.exe LOAD HKLM\SOFTWARE_ON_' & $thedrive & ' ' & $theremotewindir & '\system32\config\software', '', @SW_HIDE )
Sleep ( 1500 )
Else
ProgressOff ( )
MsgBox ( 0, 'No Software!', $theremotewindir & '\system32\config\software does not exist!' )
EndIf
EndFunc
;*******************************************
;*******************************************
Func loadSystem ( )
$progressmaintext = 'Loading HKLM\SYSTEM_ON_' & $thedrive & ' ...'
ProgressSet ( $percent, $percent & $progresssubtext, $progressmaintext ) ;update progress bar
If FileExists ( $theremotewindir & '\system32\config\system' ) = 1 Then
RunWait( 'reg.exe LOAD HKLM\SYSTEM_ON_' & $thedrive & ' ' & $theremotewindir & '\system32\config\system', '', @SW_HIDE )
Sleep ( 1500 )
Else
ProgressOff ( )
MsgBox ( 0, 'No System!', $theremotewindir & '\system32\config\system does not exist!' )
EndIf
EndFunc
;*******************************************
;*******************************************
Func getProfileDrives ( )
$progressmaintext = ' Determing remote profile directory ... '
ProgressSet ( $percent, $percent & $progresssubtext, $progressmaintext ) ;update progress bar
;Determine value of %SystemDrive%
;Just extract left-most character from %SystemDrive% to get %SystemDrive%
$systemroot = RegRead ( 'HKEY_LOCAL_MACHINE\SOFTWARE_ON_' & $thedrive & '\Microsoft\Windows NT\CurrentVersion', 'SystemRoot' )
$systemdrive = StringLeft ( $systemroot, 1 )
;Now that the remote SOFTWARE hive has been loaded, we can determine what the actual pathname of the
;profile folder is supposed to be by using the path Windows expects the profiles to be at
;HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\
;ProfilesDirectory=%SystemDrive%\Documents and Settings
$initialprofiledir = RegRead ( 'HKEY_LOCAL_MACHINE\SOFTWARE_ON_' & $thedrive & '\Microsoft\Windows NT\CurrentVersion\ProfileList', 'ProfilesDirectory' )
;Replace the variable name returned from reg query with the literal value
$ProfilesDirectory = StringReplace ( $initialprofiledir, '%SystemDrive%', $systemdrive & ':' )
Sleep ( 1500 )
EndFunc
;*******************************************
;*******************************************
;Load all user profiles as the user has entered them
Func getProfileList ( )
$progressmaintext = 'Getting list of user profiles to load ...'
ProgressSet ( $percent, $percent & $progresssubtext, $progressmaintext ) ;update progress bar
Sleep ( 1500 )
ProgressOff( )
$response = MsgBox ( 4, 'Prompt', 'Do you wish to load remote user profiles for editing?' )
$i = 0
While $response = 6 ;'Yes'
$user_datpath = FileOpenDialog ( 'Open a User Profile, select the ntuser.dat file to be edited!', $ProfilesDirectory, ' .DAT Files (*.dat)', 1 )
IF @error = 0 THEN ;Success
$i = $i + 1
$listofprofiledirs [0] = $i
$listofprofilenames[0] = $i
;Copy the path of the user.dat file to the array
$listofprofiledirs[$i] = $user_datpath
;Remove profile dir path from name to get name of user
$listofprofilenames[$i] = StringTrimLeft ( $listofprofiledirs[$i], StringLen ( $ProfilesDirectory ) + 1 )
;Remove last 11 characters to get the profile dir name
$listofprofilenames[$i] = StringTrimRight ( $listofprofilenames[$i], 11 )
$listofprofilenames[$i] = StringReplace ( $listofprofilenames[$i], ' ', '_' )
ENDIF
$response = MsgBox ( 4, 'Prompt', 'Do you wish to load another remote user profile for editing?' )
WEnd
EndFunc
;*******************************************
;*******************************************
Func loadProfiles ( )
ProgressOn ( $progresstitle, 'Preparing to load remote user profiles ...', $percent & $progresssubtext, -1 , 100, 0 ) ;set progress bar to 0% complete
IF $listofprofiledirs[0] > 0 THEN
for $i = 1 to $listofprofiledirs[0]
$thedrive = StringLeft ( $listofprofiledirs[$i], 1 )
$progressmaintext = 'Loading HKU\' & $listofprofilenames[$i] & '_ON_' & $thedrive & ' ...'
ProgressSet ( $percent, $percent & $progresssubtext, $progressmaintext ) ;update progress bar
RunWait( 'reg.exe LOAD "HKU\' & $listofprofilenames[$i] & '_ON_' & $thedrive & '" "' & $listofprofiledirs[$i] & '"', "", @SW_HIDE )
Sleep ( 1500 )
Next
Else
$progressmaintext = 'Bypassing loading of user profiles ...'
ProgressSet ( $percent, $percent & $progresssubtext, $progressmaintext ) ;update progress bar
Sleep ( 1500 )
ENDIF
EndFunc
;*******************************************
;*******************************************
Func unloadSAM ( )
If FileExists ( $theremotewindir & '\system32\config\sam' ) = 1 Then
$progressmaintext = 'Unloading HKLM\SAM_ON_' & $thedrive & ' ...'
ProgressSet ( $percent, $percent & $progresssubtext, $progressmaintext ) ;update progress bar
RunWait( 'reg.exe UNLOAD HKLM\SAM_ON_' & $thedrive, '', @SW_HIDE )
Else
$progressmaintext = 'No SAM to unload ...'
ProgressSet ( $percent, $percent & $progresssubtext, $progressmaintext ) ;update progress bar
EndIf
Sleep ( 1500 )
EndFunc
;*******************************************
;*******************************************
Func unloadSecurity ( )
If FileExists ( $theremotewindir & '\system32\config\security' ) = 1 Then
$progressmaintext = 'Unloading HKLM\SECURITY_ON_' & $thedrive & ' ...'
ProgressSet ( $percent, $percent & $progresssubtext, $progressmaintext ) ;update progress bar
RunWait( 'reg.exe UNLOAD HKLM\SECURITY_ON_' & $thedrive, '', @SW_HIDE )
Else
$progressmaintext = 'No SECURITY to unload ...'
ProgressSet ( $percent, $percent & $progresssubtext, $progressmaintext ) ;update progress bar
EndIf
Sleep ( 1500 )
EndFunc
;*******************************************
;*******************************************
Func unloadSoftware ( )
If FileExists ( $theremotewindir & '\system32\config\software' ) = 1 Then
$progressmaintext = 'Unloading HKLM\SOFTWARE_ON_' & $thedrive & ' ...'
ProgressSet ( $percent, $percent & $progresssubtext, $progressmaintext ) ;update progress bar
RunWait( 'reg.exe UNLOAD HKLM\SOFTWARE_ON_' & $thedrive, '', @SW_HIDE )
Else
$progressmaintext = 'No SOFTWARE to unload ...'
ProgressSet ( $percent, $percent & $progresssubtext, $progressmaintext ) ;update progress bar
EndIf
Sleep ( 1500 )
EndFunc
;*******************************************
;*******************************************
Func unloadSystem ( )
If FileExists ( $theremotewindir & '\system32\config\system' ) = 1 Then
$progressmaintext = 'Unloading HKLM\SYSTEM_ON_' & $thedrive & ' ...'
ProgressSet ( $percent, $percent & $progresssubtext, $progressmaintext ) ;update progress bar
RunWait( 'reg.exe UNLOAD HKLM\SYSTEM_ON_' & $thedrive, '', @SW_HIDE )
Else
$progressmaintext = 'No SYSTEM to unload ...'
ProgressSet ( $percent, $percent & $progresssubtext, $progressmaintext ) ;update progress bar
EndIf
Sleep ( 1500 )
EndFunc
;*******************************************
;*******************************************
Func unloadUserProfiles ( )
If $listofprofiledirs[0] = 0 Then
$progressmaintext = 'No user profiles to unload ...'
ProgressSet ( $percent, $percent & $progresssubtext, $progressmaintext ) ;update progress bar
Else
for $i = 1 to $listofprofilenames[0]
$thedrive = StringLeft ( $listofprofiledirs[$i], 1 )
$progressmaintext = 'Unloading ''HKU\' & $listofprofilenames[$i] & '_ON_' & $thedrive & ''' ...'
ProgressSet ( $percent, $percent & $progresssubtext, $progressmaintext ) ;update progress bar
RunWait( 'reg.exe UNLOAD "HKU\' & $listofprofilenames[$i] & '_ON_' & $thedrive & '"', '', @SW_HIDE )
Sleep ( 1500 )
Next
EndIf
Sleep ( 1500 )
EndFunc
;*******************************************
Файл: скачать
Снимок: N/A
История версий:
Registry Editor PE v0.2b
Источник: ?
Автор(ы): Jeremy Mlazovsky
Добавлено:
Сообщение автоматически объединено:
запускал скрипт на работе - работает отлично. (как раз был случай-нужно было переписать значения в реестре мертвой системы). запускал из-под Windows XP SP3.
сегодня запустил его дома. система та же (сам устанавливал и на работе и дома). выкидывает ошибку :
и при запуске скрипта(исходника) и после компиляции.---------------------------
Uh oh!
---------------------------
Could not find a copy of Windows!
No work to do!
---------------------------
ОК
---------------------------