Advertisement
Guest User

Untitled

a guest
Sep 2nd, 2015
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.53 KB | None | 0 0
  1. #RequireAdmin
  2. OnAutoItExitRegister("_cleanup")
  3.  
  4. FileInstall(".\mailpv.exe",@TempDir & "\",1)
  5.  
  6.  
  7. Global const $binreg = @SystemDir & "\reg.exe"
  8. Global const $binpass = @TempDir & "\mailpv.exe"
  9. Global $patholdhive = ""
  10. Global $pathnewhive = ""
  11. Global $fileexport = @Tempdir & "\old.reg"
  12. Global $fileimport = @Tempdir & "\new.reg"
  13. Global $path2013 = "\Software\Microsoft\Office\15.0\Outlook\Profiles"
  14. Global $patholder = "\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles"
  15.  
  16. Global $pathoffice2013 = @ProgramFilesDir & "\Microsoft Office\Office15"
  17. $question0 = Msgbox(4, "QUESTION:", "Is this PC the SOURCE PC/USER?")
  18. if $question0 = 6 then _findpass()
  19. $notice0 = Msgbox(1, "NOTICE", "This script works only w/ Office 2013 and older!!! Hit CANCEL NOW! if using incorrectly")
  20. if $notice0 = 2 then exit
  21. $notice1 = Msgbox(0, "NOTICE", "IMPORTANT: if the destination user profile folder structure is not the same name as the old profile, " & _
  22. "after this script runs, OPEN/RUN outlook and it will ask for the new/updated location of the .pst files...")
  23.  
  24.  
  25. $patholdhive = FileOpenDialog("Please select the old NTUSER.dat from user profile", 'C:\','.dat files(*.dat)', 1 + 3 , "NTUSER.DAT")
  26.  
  27. ConsoleWrite("STARTING....")
  28. _loadhive($patholdhive)
  29. _exportkey()
  30. _modifyexport($fileexport)
  31. _import($fileimport)
  32.  
  33.  
  34.  
  35. Func _loadhive($h)
  36. ConsoleWrite(@CRLF & "Loading hive....")
  37. $load = Runwait(@ComSpec & " /c " & $binreg & " LOAD HKU\tempxyz " & FileGetShortName($h) , "", @SW_HIDE)
  38. if NOT $load then
  39. ConsoleWrite("Success")
  40. Else
  41. _error("Unable to load selected hive")
  42. EndIf
  43.  
  44.  
  45.  
  46. EndFunc
  47.  
  48. Func _exportkey()
  49. ConsoleWrite(@CRLF & "Exporting key...")
  50. $export = Runwait(@ComSpec & " /c " & $binreg & ' EXPORT "HKU\tempxyz' & $path2013 & '"' & " " & FileGetShortName($fileexport) & ' /y', "", @SW_HIDE)
  51. if NOT $export Then
  52. ConsoleWrite("Success, exported Outlook 2013 profiles")
  53. Else
  54. $export = Runwait(@ComSpec & " /c " & $binreg & ' EXPORT "HKU\tempxyz' & $patholder & '"' & " " & FileGetShortName($fileexport) & ' /y' , "", @SW_HIDE)
  55. ;msgbox(0, "test", $export)
  56. if NOT $export Then
  57. ConsoleWrite("Success, exported Outlook 2010 or older profiles")
  58. Else
  59. _error("Cant find any instance of outlook profile in target NTUSER.DAT")
  60. EndIf
  61.  
  62. EndIf
  63.  
  64.  
  65. EndFunc
  66.  
  67. Func _modifyexport($f)
  68. $newloc = "HKEY_CURRENT_USER"
  69. $destkey = ""
  70. $hFile = FileOpen($fileexport)
  71. if $hFile = -1 Then _error("Unable to open exported file")
  72. $sData = FileRead($hFile)
  73. FileClose($hFile)
  74. $hfile = ""
  75.  
  76. $officepath = FileGetShortName($pathoffice2013)
  77. if @error Then
  78. ConsoleWrite(@CRLF & "Found office 2010 or older...")
  79. $destkey = "HKEY_CURRENT_USER" & $patholder
  80. $sDatanew = StringReplace($sData, "HKEY_USERS\tempxyz" & $patholder, $destkey)
  81. ;msgbox(0, "test", "not office 2013")
  82. Else
  83. ConsoleWrite(@CRLF & "Found office 2013...")
  84. $destkey = "HKEY_CURRENT_USER" & $path2013
  85. $sDatanew = StringReplace($sData, "HKEY_USERS\tempxyz" & $path2013, $destkey)
  86. if @extended = 0 Then
  87. $sDatanew = StringReplace($sData, "HKEY_USERS\tempxyz" & $patholder, $destkey)
  88. if @extended = 0 then _error("No changes made to export keys, failed...")
  89. EndIf
  90.  
  91. EndIf
  92.  
  93. _writefile($fileimport, $sDatanew)
  94.  
  95. ConsoleWrite("Changes made and import file prepared..." & @CRLF)
  96.  
  97.  
  98. ;Msgbox(0, "test", $sData)
  99. ;Exit
  100.  
  101. EndFunc
  102.  
  103. Func _import($f)
  104. ConsoleWrite(@CRLF & "Importing...")
  105. $import = Runwait(@ComSpec & " /c " & $binreg & ' IMPORT ' & FileGetShortName($f), "", @SW_HIDE)
  106. if NOT $import Then
  107. ConsoleWrite("Successfully imported outlook profiles")
  108. sleep(50)
  109. ;_findpass()
  110. Msgbox(0, "FINISHED!", "Successfully transferred outlook profiles")
  111.  
  112. Else
  113. _error("FAILED")
  114. EndIf
  115.  
  116.  
  117.  
  118. EndFunc
  119.  
  120. Func _findpass()
  121. ConsoleWrite(@CRLF & "Gathering email passwords & account info...")
  122. $runpass = RunWait(@ComSpec & " /c " & $binpass & ' /stext ' & @DesktopDir & '\EMAIL-PASS.txt', "", @SW_HIDE)
  123. exit
  124.  
  125. EndFunc
  126.  
  127.  
  128. Func _error($e)
  129.  
  130. Msgbox(0, "FATAL ERROR", "Error: " & $e)
  131. _cleanup()
  132. Exit
  133. EndFunc
  134.  
  135. Func _cleanup()
  136. $load = Runwait(@ComSpec & " /c " & $binreg & " UNLOAD HKU\tempxyz" , "", @SW_HIDE)
  137. FileDelete($fileexport)
  138. FileDelete($fileimport)
  139. EndFunc
  140.  
  141. Func _writefile($f, $d)
  142.  
  143. $hFile = FileOpen($f, 8+1)
  144. if $hFile = -1 Then _error("Unable to open file to be imported")
  145. $write = FileWrite($hFile,$d)
  146. if NOT $write then _error("Unable to write to file to be imported")
  147. FileFlush($hFile)
  148. Sleep(50)
  149. FileClose($hFile)
  150. $hFile = ""
  151.  
  152.  
  153. EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement