DB25
Fresh Scripter
Registered: 2008-03-20
Posts: 14
|
I found this script....but I don't think it's going to do what I need it to do...can someone take a look please? Thanks!
What I want to do is Move users psts to another sharedrive and create their folder path for example
move from: \\server\username\thepst.pst
move to: \\server\username\thepst.pst
Script:
;----------------- ; Move_PST_PAB.txt ;----------------- ; This Kixtart script file will move a user's Personal ; Folders and Personal Address Book to a new location ; By doing the following: ; ; Kixtart: ; - Prompt the User ; - Copy the file to new location ; - Rename the old file so that ; Outlook can't find it. ; - Create and call an AutoIt Script ; AutoIt: ; - Open Outlook 97 ; - If an error about the PAB file appears, ; Type the new location of the address book ; - Go to Tools/Services ; - Select each Service that has changed locations ; - When Outlook prompts for the new path to the file ; type it in. ; - Exit Outlook ; ; You can obtain AutoIt for free from: ; http://www.hidden.demon.co.uk/AutoIt/index.html ;-----------------
;........................................ ; Change the following two variables to ; match the path where you want PST and ; PAB files to be moved to: ;........................................ $ExchangeFileLoc = "C:\Exchange" $ExchangeHomeDrive = "C:"
;........................................ ; Set the following variable to be the ; name of your support team. ; This is used to create custom entries ; in the Registry ;........................................ $SupportGroup = "EASG"
;........................................ ; The following variable points to the ; location of the AutoIt.exe file ; You can obtain AutoIt from http://www.hidden.demon.co.uk/AutoIt/index.html ;........................................ $AutoItPath = @LDrive + "\US\NY\MLCSIM\Autoit.exe
;........................................ ; Initialize Generic Variables ;........................................ $ProfileCount = 0 $MsgKey = "HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles" $ExchangeFileType = "" $WantFileMoved = "No" $ServiceCount=2 ;........................................ ; The following key is used to track what ; files need to be migrated ;........................................ $RC=ADDKEY("HKEY_CURRENT_USER\Software\" + $SupportGroup + " Controlled Apps\NT_Migration")
;........................................ ; The User's home server is determined ; based on their Home Share ; (If no Home Share is defined, this ; script won't work) ;........................................ IF LEN(@HOMESHR) > 0 $HomeDeptServer=SUBSTR(SUBSTR(@HOMESHR,3,len(@HOMESHR)-2),1,instr(SUBSTR(@HOMESHR,3,len(@HOMESHR)-2),"\")-1) ELSE $HomeDeptServer="UNKNOWN" EXIT 0 ENDIF
;........................................ ; Delve into the registry to find Info ; About what PSTs and PABs are set up ;........................................ DO $MProfile=EnumKey($MsgKey, $ProfileCount) IF @ERROR=0 IF Len( $MProfile ) $SettingCount = 0 DO $MSetting=EnumKey($MsgKey + "\" + $MProfile, $SettingCount) IF @ERROR=0 IF Len( $MSetting ) $ValueName=ReadValue($MsgKey + "\" + $MProfile + "\" + $MSetting, "001e3001") IF @ERROR=0 ;? $ValueName ENDIF
;--- PST Files $FileLocation=ReadValue($MsgKey + "\" + $MProfile + "\" + $MSetting, "001e6700") IF @ERROR=0 $ExchangeFileType = "Personal Folder" GOSUB ProcessHere ENDIF
;--- PAB Files $FileLocation=ReadValue($MsgKey + "\" + $MProfile + "\" + $MSetting, "001e6600") IF @ERROR=0 $ExchangeFileType = "Personal Address Book" GOSUB ProcessHere ENDIF ENDIF ENDIF $SettingCount = $SettingCount + 1 UNTIL Len( $MSetting ) = 0 ENDIF ENDIF $ProfileCount = $ProfileCount + 1 UNTIL Len( $MProfile ) = 0
IF $WantFileMoved = "Yes" GOSUB MakeFooter ;............................................ ; Execute the AutoIt script that was created ;............................................ SHELL $AutoItPath + " " + $ExchangeHomeDrive + "\_ExFil.txt" ENDIF
EXIT 0
;------------------ :StripPath ;------------------ ; This routine will take the UNC path and parse it out ; Into a filename and a name that the original file ; will be renamed to. (pab becomes paX while pst becomes psX) ;------------------ $FileName = substr($FileLocation,3,500) WHILE INSTR($FileName,"\") > 0 $FileName = SUBSTR($FileName,INSTR($FileName,"\")+1,500) LOOP $RenFileName = SUBSTR($FileName, 1, len($FileName) -1) + "X" RETURN
;------------------ :ProcessHere ;------------------ ; This routine will prompt the user if they want to move each ; eligible file to it's new location. ; If they say yes, an AutoIt script file is built which will ; handle the transfer ;------------------ $ServiceCount = $ServiceCount + 1
;........................................... ; If the file has already been moved to the ; New destination, don't do anything ;........................................... IF SUBSTR($FileLocation, 1, len($ExchangeFileLoc)) = $ExchangeFileLoc Return ENDIF $RC = READVALUE("HKEY_CURRENT_USER\Software\" + $SupportGroup + " Controlled Apps\NT_Migration",$FileLocation) IF @ERROR=0 ;--- This File has already been processed Return ENDIF
;? $ExchangeFileType + ": " + $ValueName ;? "Previous Location: " + $FileLocation GOSUB StripPath ;? "New Location: " + $ExchangeFileLoc + "\" + $FileName ;? "Renamed File: " + $RenFileName ?
$MigrationComplete = "No" $RC=MESSAGEBOX("Would you like to move your Outlook " + $ExchangeFileType + " named '" + $ValueName + "' from it's current location at " + $FileLocation + " to your personal directory on the new NT Server, " + $HomeDeptServer + " at this time?" , "Windows NT Migration", 4 + 4096)
IF $RC = 7 ;--- They said no $RC = MESSAGEBOX("Do you want to move it later?", "Windows NT Migration", 4 + 4096) IF $RC = 7 ;--- They said no again $RC=WRITEVALUE("HKEY_CURRENT_USER\Software\" + $SupportGroup + " Controlled Apps\NT_Migration",$FileLocation,"DontMove","REG_SZ") RETURN ELSE ;--- They will move it later RETURN ENDIF ELSE ;--- They said yes they want to move it now IF $WantFileMoved = "No" GOSUB MakeHeader ENDIF IF $ExchangeFileType = "Personal Folder" GOSUB MakeBody ELSE $PABFileName = $FileName ENDIF
IF EXIST ("\\" + $HomeDeptServer + "\" + @USERID + "$" + "\_ExFil.txt") MD $ExchangeFileLoc $RC=setconsole("MAXIMIZE") COLOR g+/n ? ? "Copying " + $FileLocation ? " to " + $ExchangeFileLoc + "\" + $FileName + "..." COPY $FileLocation $ExchangeFileLoc + "\" + $FileName SHELL 'cmd.exe /c ren "' + $FileLocation + '" "' + $RenFileName + '"'
? "Done." ? COLOR w/n ELSE MESSAGEBOX("Your " + $ExchangeHomeDrive + " drive is not mapped correctly!" + chr(10) + "Please Submit A ticket","Windows NT Migration",4096) EXIT 1 ENDIF ENDIF
:EndProcessHere
RETURN
;------------------ :MakeHeader ;------------------ ; This will create the top of the AutoIt Script ;------------------ $WantFileMoved = "Yes" ; Read the path to Microsoft Outlook from the registry. $OutlookPath = READVALUE("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MOS\Mail", "Inbox") ;IF EXIST($ExchangeHomeDrive + "\_ExFil.txt") DEL($ExchangeHomeDrive + "\_ExFil.txt") ENDIF $RC=REDirectOutput($ExchangeHomeDrive + "\_ExFil.txt", 1) ? 'Run, "' + $OutlookPath + '"' ? "WinWaitActive, Inbox - Micros" ? "Send, !T" ? "Send, v" $RC=REDirectOutput("") RETURN
;------------------ :MakeBody ;------------------ ; Each file that is to be moved will be added to the body of ; the AutoIt script Here. ;------------------ $RC=REDirectOutput($ExchangeHomeDrive + "\_ExFil.txt", 0) ? ? "Goto, FirstLetter" ? "TryAgain:" ? "Send, {ESC}" ? "FirstLetter:" ? "WinWaitActive, Services" ? "Send, " + SUBSTR($ValueName,1,1) ? "sleep 2000" ? ";Get Properties for the selected Service" ? "Send, !r" ? "sleep 500" ? "IfWinNotActive, " + $ExchangeFileType + ", The file " + $FileLocation + ", TryAgain" ? "Send, {ENTER}" ? "WinWaitActive, Create/Open" ? "Send, " + $ExchangeFileLoc + "\" + $FileName + "#{ENTER}" ? ";Say OK to this service" ? "WinWaitActive, " + $ExchangeFileType + ", Name" ? "Send, +{TAB}#+{TAB}#+{TAB}#+{TAB}#{ENTER}"
$RC=REDirectOutput("") RETURN
;------------------ :MakeFooter ;------------------ ; This will create the bottom of the AutoIt script ;------------------ $RC=REDirectOutput($ExchangeHomeDrive + "\_ExFil.txt", 0) ? ? ";Exit Services" ? "Send, +{TAB}#+{TAB}#+{TAB}#+{TAB}#{ENTER}" ? "WinWaitActive, Inbox - Micros" ? "Send, !{F4}" ? "Goto, Done" ? "Error:" ? "Run, Notepad.exe" ? "WinWaitActive, Untitled - No" ? "Send, Your Personal Folder could not be moved.{ENTER} Please Submit A ticket." ? "Exit" ? "Done:" ? "exit" ? ? "[ADLIB]" ? "Personal Address Book Logon,,Y" ? "Personal Address Book, Name,{TAB}#" + $ExchangeFileLoc + "\" + $PABFileName + "{TAB}{TAB}{TAB}{ENTER}" $RC=REDirectOutput("") RETURN
|