$RC = SetOption("WOW64AlternateRegView","On")
$Rc = SetOption('NoVarsInStrings', 'On')
$Rc = SetOption('NoMacrosInStrings', 'On')
$RC = SetConsole('SHOW')
; Provide the user a popup message asking them if they want to proceed with this script or to exit.
If MessageBox ("This will rebuild your Outlook profile, Do you wish to continue? Press YES to rebuild your outlook profile, or press NO to cancel", " Rebuild Outlook profile on Launchpad servers", 36) = 6
; Now we're going to start deleteing data
$RC = MessageBox ("Once you click OK on this message the Outlook reset process will start. Please wait until you see another message informing you the rebuild has completed before using any office applications..", " Outlook profile rebuild on PS Launchpad servers started.....", 0, 10)
$RC = EnumProcess("outlook.exe",1)
$RC = EnumProcess("ObClnt32.exe",1)
$RC = EnumProcess("obunity.exe",1)
DEL "\\netshare\userconfigs$\"+@userid+"\PsCitrixConfig\Outlook\Outlookran.txt" /c
DEL "\\netshare\userconfigs$\"+@userid+"\PSCitrixConfig\Outlook\OutlookMessaging.reg" /c
DEL "\\netshare\userconfigs$\"+@userid+"\PSCitrixConfig\Outlook\Office.reg" /c
$RC = DELTREE("HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem")
$RC = DELVALUE("HKCU\Software\Microsoft\Office\14.0\Outlook\Setup", "FirstRun")
$RC = DELVALUE("HKCU\Software\Microsoft\Office\14.0\Outlook\Setup", "First-Run")
$RC = DELVALUE("HKCU\Software\Microsoft\Office\14.0\Outlook\Setup", "ImportPRF")
RD "%userprofile%\Appdata\Local\Microsoft\Outlook" /s
RD "%userprofile%\Appdata\Roaming\Microsoft\Outlook" /s
MD "%userprofile%\Appdata\Local\Microsoft\Outlook"
MD "%userprofile%\Appdata\Roaming\Microsoft\Outlook"
$RC = WriteValue("HKCU\Software\Microsoft\Office\14.0\Outlook\Setup", "FirstRun", "0", "REG_DWORD")
$RC = WriteValue("HKCU\Software\Microsoft\Office\14.0\Outlook\Setup", "First-Run", "0", "REG_DWORD")
$RC = WriteValue("HKCU\Software\Microsoft\Office\14.0\Outlook\Setup", "ImportPRF", "c:\Progra~2\Micros~2\Custom14.prf", "REG_SZ")
Run "%ProgramFiles%\Microsoft\Office\Outlook.exe"
SLEEP 13
$RC = EnumProcess("outlook.exe",1)
$RC = EnumProcess("ObClnt32.exe",1)
$RC = EnumProcess("obunity.exe",1)
COPY "c:\Scripts\OutlookRan.txt" "\\netshare\userconfigs$\"+@userid+"\PSCitrixConfig\Outlook"
SHELL '%comspec% /c Reg Export "HKCU\Software\Microsoft\Office" "\\netshare\userconfigs$\'+@userid+'\PSCitrixConfig\Outlook\Office.reg"'
$RC = MessageBox ("Your Outlook profile has been Rebuilt, and your e-mail should now work properly. If you continue to have problems with using Outlook, please open a Helpdesk or contact extention 2500.", " Outlook Profile Rebuild Completed!", 0, 10)
ENDIF
EXIT 0
FUNCTION EnumProcess($exe, optional $terminate, optional $Computer)
Dim $winmgmts, $ExecQuery, $Process, $id, $getobject, $
If NOT $computer
$computer = @wksta
Endif
$winmgmts="winmgmts:{impersonationLevel=impersonate}!//$COMPUTER"
Select
Case val($exe)>0
$ExecQuery="select * from Win32_Process where ProcessId='$exe'"
$GetObject=GetObject($winmgmts).ExecQuery($ExecQuery)
For Each $Process in $GetObject
If $terminate
$ = $Process.Terminate
Endif
$EnumProcess = $Process.name
Next
$GetObject=''
Case vartype($exe)=8
$ExecQuery="select * from Win32_Process where Name='$exe'"
$GetObject=GetObject($winmgmts).ExecQuery($ExecQuery)
For Each $Process in $GetObject
If $terminate
$=$Process.Terminate
Endif
$id=$Process.ProcessId
$EnumProcess = "$Id" + "|" + "$EnumProcess"
Next
$EnumProcess=left($EnumProcess,len($EnumProcess)-1)
$GetObject=''
Case 1
Exit 1
EndSelect
ENDFUNCTION