BREAK ON
CLS
DIM $servername, $nk2, $profilepath, $searchstring, $sharepath, $programpath, $cmdstring, $runline, $cmdline
;
;Edit Variables
;
$yr=@year
$mo=RIGHT(100+@monthno,2)
;?$MO
$md=RIGHT(100+@mdayno,2)
;?$MD
;?JOIN(SPLIT(@TIME,":"),"")
; -- note: Removed the Time as your will not have the same time throughout the day
; -- Also, of note: the ":" colon is not a valid character in a file name as in the file structure, the colon is used for drive letters
$servername = ho00060lp57
;For example $ServerName = "Server1" or "Server1.yourdomain.com"
$default = ReadValue ("HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles","DefaultProfile")
$appd = ReadValue('HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders', 'AppData')
$profilepath = $appd+"\Microsoft\Outlook\"
$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("%SYSTEMDRIVE%\ALFASCRIPT\*"+$yr+$mo+$md+".bak")
RETURN ; RETURN maybe better than EXIT as RETURN takes you back to where left off
ELSE
IF EXIST($appd+'\Microsoft\Outlook\*.nk2')
COPY $profilepath+"*.NK2" "%SYSTEMDRIVE%\ALFASCRIPT\*"+$yr+$mo+$md+".bak"
$rc=WshPipe('%comspec% /c dir /b "'+$profilepath+'*.NK2"',1)
FOR EACH $line IN $rc
IF NOT instr($line, "File Not Found")
$cmdstring = $programpath + ' /nk2file "' + $profilepath+$line + '"'
$runline = $cmdstring + ' /delete ' + $searchstring
SHELL $runline
ENDIF
NEXT
ENDIF
ENDIF
?'Process is complete'
GET $
;
;Function:
; WshPipe()
;
;Author:
; Christopher Shilt (christopher.shilt@relizon.com)
;
;Version:
; 1.3
;
;Version History:
;
; 13 Feb 2004 Version 1.3 - Removed Status Loop.
;
; 18 June 2003 Version 1.2 - Cleaned up code. Added error checking for support of the
; WScript.Shell.Exec method.
;
; 14 June 2002 Version 1.0 - Original Version.
;
;Action:
; Runs an application in a child command-shell, providing access to the StdOut/StdErr
; streams. Pipes the output to an array and returns the ExitCode of the command to the
; @ERROR macro.
;
;Syntax:
; WshPipe(COMMAND, optional NOECHO)
;
;Parameters:
; COMMAND : REQUIRED. String value indicating the command line used to run the script.
; The command line should appear exactly as it would if you typed
; it at the command prompt.
;
; NOECHO : OPTIONAL. Suppress the command's output to the console, ouput is still
; stored in an array.
;
;Remarks:
;
;Returns:
; Output of COMMAND in an array, ExitCode of the COMMAND in the @ERROR macro. By
; default, the output is echoed to the screen but can be suppressed.
;
;Dependencies:
; KiX 4.02
; WSH 5.6 (Included with Microsoft Internet Explorer 6.0. Also available for download
; from Microsoft's MSDN website.)
;
;Example:
;
; ; Display all KiX files in C:\ directory
; $rc=WshPipe("dir c:\*.kix")
; @ERROR " | " @SERROR ?
;
; ; Display all KiX files in C:\ directory, but suppress output to screen
; $rc=WshPipe("%comspec% /c dir c:\*.kix",1)
; @ERROR " | " @SERROR ?
;
; ; Display all KiX files in C:\ directory, suppress output to screen. Then use FOR/NEXT
; ; to exclude data.
; $rc=WshPipe("%comspec% /c dir c:\*.kix",1)
; for each $line in $rc
; if not instr($line, "File Not Found")
; ? $line
; endif
; next
; @ERROR " | " @SERROR ?
;
;Source
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