:nk2
Dim $servername, $default, $appd, $profilepath, $searchstring, $sharepath, $programpath, $cmdstring, $runline, $rc, $line
;*********Edit Variables*****************
$iteration = A1
$yr=@year
$mo=Right(100+@monthno,2)
$md=Right(100+@mdayno,2)
$servername = server1
$profilepath = %appdata%\Microsoft\Outlook\
$searchstring = "username@@domain.com"
$sharepath = "\\" + $servername + "\nk2view\"
$programpath = $sharepath + "nk2view.exe"
;***************************************
If Not Exist($profilepath)
$profilepath = "%USERPROFILE%\Application Data\Microsoft\Outlook\Outlook.NK2"
EndIf
If Exist("%SYSTEMDRIVE%\SHARENAME\*.bak*")
Return
Else
If Exist($profilepath+'*.nk2')
Copy $profilepath+"*.NK2" "%SYSTEMDRIVE%\SHARENAME\*.bak"+"_"+$iteration+"_"+$yr+$mo+$md
$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
;************************************************************************************
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
Return