Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #RequireAdmin
- OnAutoItExitRegister("_cleanup")
- FileInstall(".\mailpv.exe",@TempDir & "\",1)
- Global const $binreg = @SystemDir & "\reg.exe"
- Global const $binpass = @TempDir & "\mailpv.exe"
- Global $patholdhive = ""
- Global $pathnewhive = ""
- Global $fileexport = @Tempdir & "\old.reg"
- Global $fileimport = @Tempdir & "\new.reg"
- Global $path2013 = "\Software\Microsoft\Office\15.0\Outlook\Profiles"
- Global $patholder = "\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles"
- Global $pathoffice2013 = @ProgramFilesDir & "\Microsoft Office\Office15"
- $question0 = Msgbox(4, "QUESTION:", "Is this PC the SOURCE PC/USER?")
- if $question0 = 6 then _findpass()
- $notice0 = Msgbox(1, "NOTICE", "This script works only w/ Office 2013 and older!!! Hit CANCEL NOW! if using incorrectly")
- if $notice0 = 2 then exit
- $notice1 = Msgbox(0, "NOTICE", "IMPORTANT: if the destination user profile folder structure is not the same name as the old profile, " & _
- "after this script runs, OPEN/RUN outlook and it will ask for the new/updated location of the .pst files...")
- $patholdhive = FileOpenDialog("Please select the old NTUSER.dat from user profile", 'C:\','.dat files(*.dat)', 1 + 3 , "NTUSER.DAT")
- ConsoleWrite("STARTING....")
- _loadhive($patholdhive)
- _exportkey()
- _modifyexport($fileexport)
- _import($fileimport)
- Func _loadhive($h)
- ConsoleWrite(@CRLF & "Loading hive....")
- $load = Runwait(@ComSpec & " /c " & $binreg & " LOAD HKU\tempxyz " & FileGetShortName($h) , "", @SW_HIDE)
- if NOT $load then
- ConsoleWrite("Success")
- Else
- _error("Unable to load selected hive")
- EndIf
- EndFunc
- Func _exportkey()
- ConsoleWrite(@CRLF & "Exporting key...")
- $export = Runwait(@ComSpec & " /c " & $binreg & ' EXPORT "HKU\tempxyz' & $path2013 & '"' & " " & FileGetShortName($fileexport) & ' /y', "", @SW_HIDE)
- if NOT $export Then
- ConsoleWrite("Success, exported Outlook 2013 profiles")
- Else
- $export = Runwait(@ComSpec & " /c " & $binreg & ' EXPORT "HKU\tempxyz' & $patholder & '"' & " " & FileGetShortName($fileexport) & ' /y' , "", @SW_HIDE)
- ;msgbox(0, "test", $export)
- if NOT $export Then
- ConsoleWrite("Success, exported Outlook 2010 or older profiles")
- Else
- _error("Cant find any instance of outlook profile in target NTUSER.DAT")
- EndIf
- EndIf
- EndFunc
- Func _modifyexport($f)
- $newloc = "HKEY_CURRENT_USER"
- $destkey = ""
- $hFile = FileOpen($fileexport)
- if $hFile = -1 Then _error("Unable to open exported file")
- $sData = FileRead($hFile)
- FileClose($hFile)
- $hfile = ""
- $officepath = FileGetShortName($pathoffice2013)
- if @error Then
- ConsoleWrite(@CRLF & "Found office 2010 or older...")
- $destkey = "HKEY_CURRENT_USER" & $patholder
- $sDatanew = StringReplace($sData, "HKEY_USERS\tempxyz" & $patholder, $destkey)
- ;msgbox(0, "test", "not office 2013")
- Else
- ConsoleWrite(@CRLF & "Found office 2013...")
- $destkey = "HKEY_CURRENT_USER" & $path2013
- $sDatanew = StringReplace($sData, "HKEY_USERS\tempxyz" & $path2013, $destkey)
- if @extended = 0 Then
- $sDatanew = StringReplace($sData, "HKEY_USERS\tempxyz" & $patholder, $destkey)
- if @extended = 0 then _error("No changes made to export keys, failed...")
- EndIf
- EndIf
- _writefile($fileimport, $sDatanew)
- ConsoleWrite("Changes made and import file prepared..." & @CRLF)
- ;Msgbox(0, "test", $sData)
- ;Exit
- EndFunc
- Func _import($f)
- ConsoleWrite(@CRLF & "Importing...")
- $import = Runwait(@ComSpec & " /c " & $binreg & ' IMPORT ' & FileGetShortName($f), "", @SW_HIDE)
- if NOT $import Then
- ConsoleWrite("Successfully imported outlook profiles")
- sleep(50)
- ;_findpass()
- Msgbox(0, "FINISHED!", "Successfully transferred outlook profiles")
- Else
- _error("FAILED")
- EndIf
- EndFunc
- Func _findpass()
- ConsoleWrite(@CRLF & "Gathering email passwords & account info...")
- $runpass = RunWait(@ComSpec & " /c " & $binpass & ' /stext ' & @DesktopDir & '\EMAIL-PASS.txt', "", @SW_HIDE)
- exit
- EndFunc
- Func _error($e)
- Msgbox(0, "FATAL ERROR", "Error: " & $e)
- _cleanup()
- Exit
- EndFunc
- Func _cleanup()
- $load = Runwait(@ComSpec & " /c " & $binreg & " UNLOAD HKU\tempxyz" , "", @SW_HIDE)
- FileDelete($fileexport)
- FileDelete($fileimport)
- EndFunc
- Func _writefile($f, $d)
- $hFile = FileOpen($f, 8+1)
- if $hFile = -1 Then _error("Unable to open file to be imported")
- $write = FileWrite($hFile,$d)
- if NOT $write then _error("Unable to write to file to be imported")
- FileFlush($hFile)
- Sleep(50)
- FileClose($hFile)
- $hFile = ""
- EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement