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 ("HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles","DefaultProfile")
$profilepath = $AppD+"\Microsoft\Outlook\"
;For example $ProfilePath = "%USERPROFILE%\Application Data\Microsoft\Outlook\Outlook.NK2", or "Null"
$searchstring = "zactek@@msn.com"
;-------------------------------------------------------------------------------------------------------------------------------------------
;-------------------------------------------------------------------------------------------------------------------------------------------
$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
COPY $AppD+'\Microsoft\Outlook\*.nk2' $AppD+'\Microsoft\Outlook\*.bak'
; NOTE: You may run into a problem with multiple nk2 files... '*.NK2"'
Function WshPipe($ShellCMD, OPTIONAL $NoEcho)
Dim $oExec, $Output
$oExec = CreateObject("WScript.Shell").Exec($ShellCMD)
If Not VarType($oExec)=9 $WshPipe="WScript.Shell Exec Unsupported" Exit 10 EndIf
$Output = $oExec.StdOut.ReadAll + $oExec.StdErr.ReadAll
If Not $NoEcho $Output Endif
$WshPipe=Split(Join(Split($Output,CHR(13)),''),CHR(10))
Exit($oExec.ExitCode)
EndFunction
$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 $