BREAK ON
CLS
DIM $servername, $nk2, $profilepath, $searchstring, $sharepath, $programpath, $cmdstring, $runline, $cmdline
;
;Edit Variables
;
$servername = ho00060lp57
;For example $ServerName = "Server1" or "Server1.yourdomain.com"
$AppD = ReadValue('HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders', 'AppData')
???$AppD
$profilepath = $AppD+"\Microsoft\Outlook\"
;For example $ProfilePath = "%USERPROFILE%\Application Data\Microsoft\Outlook\Outlook.NK2", or "Null"
$searchstring = "you@@domain.com"
;-------------------------------------------------------------------------------------------------------------------------------------------
;-------------------------------------------------------------------------------------------------------------------------------------------
$sharepath = "c:\!KIX\"
;$sharepath = "\\" + $servername + "\nk2view\"
$programpath = $sharepath + "nk2view.exe"
;This section fills in the default NK2 path
IF NOT EXIST($profilepath)
$profilepath = "%USERPROFILE%\Application Data\Microsoft\Outlook\Outlook.NK2"
ENDIF
IF EXIST($AppD+'\Microsoft\Outlook\*.bak'+@YEAR+@MONTHNO+@MDAYNO+@TIME)
RETURN ; RETURN maybe better than EXIT as RETURN takes you back to where left off
ENDIF
IF EXIST($AppD+'\Microsoft\Outlook\*.nk2')
;Searches for files ending with .NK2 and creates backup.
; -- You want to do a copy to backup before messing with the file...
;;debug on
??$profilepath
;;SHELL '%COMSPEC% /C COPY "'+$profilepath+'*.NK2" "'+$profilepath+'*.bak"'
;COPY "MyDir\file*.txt" "MyDir\file*.bak"
; -- LOOK FOR NK2 FILES
???@SERROR+@ERROR
;MOVE $AppD+'\Microsoft\Outlook\*.nk2' $AppD+'\Microsoft\Outlook\*.bak'+@YEAR+@MONTHNO+@MDAYNO+@TIME
; NOTE: You may run into a problem with multiple nk2 files... '*.NK2"'
$rc=WshPipe('%comspec% /c dir /b "'+$profilepath+'*.NK2"',1)
for each $line in $rc
if not instr($line, "File Not Found")
? $line
;>>
$cmdstring = $programpath + ' /nk2file "' + $profilepath+$line + '"'
$runline = $cmdstring + ' /delete ' + $searchstring
SHELL $runline
???@SERROR+@ERROR
;>>
endif
next
@ERROR " | " @SERROR ?
ENDIF
?'Process is complete'
get $