|
|
|||||||||
|
|||||||||
|
|||||||||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
|
|
#1
|
|||
|
|||
|
Alert if certain file type exceed specified limit.
Hi there,
I have the following script that alerts me when my ost file reaches a certain size, set by what is in the script. ---------------------- Option Explicit Dim FSO, File, strSize, strFile, alarmSize, WshShell, objshell, intMessage ' As scheduled scripts dont like arguments tell the script which file to check strFile="C:\Documents and Settings\camjp5\My Documents\Exchange\outlook.ost" ' The size to check against in Megabytes alarmSize=2 Set FSO = CreateObject("Scripting.FileSystemObject") Set File = FSO.GetFile("C:\Documents and Settings\camjp5\My Documents\Exchange\outlook.ost") strSize = File.Size\1024\1024 If strSize > alarmSize Then Set objshell = CreateObject("Wscript.Shell") intMessage = Msgbox("Attention: Your Mailbox size is " & strSize & "Mb. The recommended limit is " & alarmSize & " Mb." & vbNewLine & vbNewLine & "You should archive your email into Personal Folders. Archiving aviods Outlook to slow down and reduces the possiblity of currupting items in you mail folders." & vbNewLine & vbNewLine & "If you wish to follow instructions on how to archive your mail click Yes. Otherwise click No.", _ vbYesNo+48, "Microsoft Outlook") If intMessage = vbYes Then ' Website or document that will host the relevant information objShell.Run("URL or document path") Else Wscript.Quit End If End If Set File = Nothing Set FSO = Nothing Wscript.Quit(1) ---------------------- It works fine, but what I want it to do it to be able to run on multiple machines, so to have the script not be specific to my local documents, as we have profiles on our machines the path would differ from user to user, and the ost file name can also differ, depending on what they have saved it as. Is there a way to just make it look for the file extension ".ost" in say 'C:\Documents and Settings' ? Any help would be much appreciated. Thanks, Julian |
|
#2
|
||||
|
||||
|
--moved to the Windows Scripting forum.
|
|
#3
|
||||
|
||||
|
if you have active directory you can create a gpo or link to the script via user account on logon...
not sure this will do it for you....but may give you an idea... Code:
sComputer = "."
Set oWMIService = GetObject("winmgmts:\\" & sComputer & "\root\cimv2")
Set colItems = oWMIService.ExecQuery("Select * From Win32_ComputerSystem")
For Each oItem in colItems
aUsrProfName = Split(oItem.UserName,"\")
sUsrProfName = aUsrProfName(1)
Next
Set FSO=CreateObject("Scripting.FileSystemObject")
If FSO.driveexists("c:") = true then
sMyDocsFolder = "c:\Documents and Settings\" & sUsrProfName & "\My Documents\"
If FSO.folderexists(sMyDocsFolder) Then
Set oMyDocsFolder = FSO.GetFolder(sMyDocsFolder)
For Each oFile in oMyDocsFolder.Files
If LCase(Right(oFile.Name, 4)) = ".ost" Then
sFileName = oFile.Name
bFileFound = true
Exit For
End If
Next
If bFileFound Then
alarmSize = 2
Set File = FSO.GetFile(sMyDocsFolder & "\" & oFile.Name)
sSize = File.Size\1024\1024
If sSize > alarmSize Then
Set objshell = CreateObject("Wscript.Shell")
iMessage = Msgbox("Attention: Your Mailbox size is " & strSize & "Mb. " & _
"The recommended limit is " & alarmSize & " Mb." & _
vbNewLine & vbNewLine & "You should archive your email " & _
"into Personal Folders. Archiving aviods Outlook to slow " & _
"down and reduces the possiblity of currupting items in " & _
"you mail folders." & vbNewLine & vbNewLine & "If you wish " & _
"to follow instructions on how to archive your mail click Yes. " & _
"Otherwise click No.", _
vbYesNo+48, "Microsoft Outlook")
If iMessage = vbYes Then
objShell.Run("URL or document path")
Else
Wscript.Quit
End If
End If
End If
End If
End If
|
|
#4
|
|||
|
|||
|
Thanks for that. Will play around and give it try
![]() |
![]() |
| Viewing: ASP Free Forums > System Administration > Windows Scripting > Alert if certain file type exceed specified limit. |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|
|