' NAME: FilesOnDesktop Agent.vbs
'
' AUTHOR: Alan Kaplan , alan dot akaplan at va dot gov
' DATE : 1/26/2007, 7/12/11
'
' COMMENT: Warns users that files on desktop are not backed up.
' You can run this in the logon script
' v 1.1 adds path and computername for help desk.
' v 1.2 uses Agent if available.
'==========================================================================
Option Explicit
dim wshShell
Set wshShell = WScript.CreateObject("WScript.Shell")
Dim strIgnore, strDesktop, message
Dim iCount
Dim strAgentName, objAgent, objCharacter, WinDir
Dim strAgentPath, bAgent
'note this Is a String listing of extensions, Not an Array
'The list is not required
strIgnore = "LNK,URL,INI,PIF,INF,HISTORY,VBS,EXE"
'if you leave in URLs, internet shortcuts are noted
'strIgnore = "LNK,INI,PIF,INF"
strDesktop = wshShell.ExpandEnvironmentStrings("%USERPROFILE%"&"\Desktop")
iCount = 0
dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
'You can edit this message
message = "If your hard drive crashes, or this computer is replaced, " & _
"you will lose these files found on your desktop:" & VbCrLf
check strDesktop
message = message & VbCrLf & VbCrLf & _
"Copy these files, internet shortcuts and any other files that you may have stored on this computer to your " & _
"network home directory now to avoid possible data loss!" & VbCrLf & VbCrLf & _
" If you need assistance, please call your Service Application Coordinator." & VbCrLf & VbCrLf & _
"Your desktop path is " & strDesktop & _
" on " & wshShell.ExpandEnvironmentStrings("%COMPUTERNAME%") & "." & VbCrLf
if iCount > 1 Then
RunAgent
IEMessage Message,"DATA LOSS WARNING!","lt Blue",600,750,True
If bAgent Then
Wscript.Sleep 5000
objCharacter.Stop
objCharacter.Hide
End If
End If
'================ Functions and Subs ==============
Sub RunAgent
strAgentName = "Merlin"
WinDir = wshShell.ExpandEnvironmentStrings("%Windir%")
strAgentPath = windir & "\Msagent\Chars\" & strAgentName & ".acs"
On Error Resume next
Set objAgent = CreateObject("Agent.Control.2")
If Err <> 0 Then
bAgent = True
Else
bAgent = False
Exit Sub
End If
objAgent.Connected = True
objAgent.Characters.Load strAgentName, strAgentPath
Set objCharacter = objAgent.Characters.Character(strAgentName)
objCharacter.Show
objCharacter.Play "GetAttention"
objCharacter.Play "Confused"
objCharacter.Speak "I am confused. Why do you have files on your desktop?"
objCharacter.Play "GestureLeft"
objCharacter.Speak "Read the warning. It is important."
Wscript.Sleep 10000
objCharacter.Play "Idle1_2"
End Sub
Sub check (fldname)
iCount = iCount + 1
On Error Resume Next
Dim subfolders,files,folder,file,fldr,ofiles,strExt,strFMessage, strFileName
Set fldr = fso.GetFolder(fldname)
Set subfolders = fldr.SubFolders
Set ofiles = fldr.Files
If iCount = 1 Then
strFMessage = "On Desktop"
Else
strFMessage = "In desktop folder "
End If
'Display the path and all of the folders.
message = message & VbCrLf & strFMessage & mid(fldr.Path,Len(strDesktop)+2) & ":" & VbCrLf
'Display all of the files.
For Each file in ofiles
strExt = ucase(fso.GetExtensionName(file.name))
If InStr(strIgnore,strExt) = 0 Then
iCount = iCount + 1
strFileName = file.name
If strExt = "URL" Then
strFileName = "[Internet Shortcut] " & strFileName
End If
message = message & string(5,"-")& "> " & strFileName & VbCrLf
End If
Next
'Recurse all of the subfolders.
For Each folder in subfolders
check folder
Next
Set subfolders = Nothing
Set files = Nothing
End Sub
Sub IEMessage(message,strTitle,strBGColor,iHeight,IWidth,bPrint)
Dim oIE, oPage
Dim strComputer, strBorder, strFont
Dim strFormatOn, strFormatOff, iTSView
Set oIE = CreateObject("InternetExplorer.Application")
iTSview = 0 '1 for troubleshooting, allows view source menu
strBorder = 1 'Best appearance is strBorder 1
strFont = "Arial"
oIE.Navigate "about:blank"
oIE.AddressBar = False
oIE.Height = iHeight
oIE.Width = IWidth
oIE.MenuBar = iTSView
oIE.ToolBar = iTSView
oIE.StatusBar = False
oIE.Left = 150
oIE.Top = 50
oIE.Visible = 1
message = Replace(message,vbcrlf,"
"& vbcrlf)
Do While (oIE.Busy)
Wscript.Sleep 250
Loop
Set oPage = oIE.Document
oPage.Open
oPage.Writeln "