I have a VBscript that will enumerate the file name in a specific folder, set it as a variable, then send it as an attachment in an email.
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
" & strComputer & "\root\cimv2")
Set colFiles = objWMIService. _
ExecQuery("Select * from CIM_DataFile where Path = '\\syncout\\'")
For Each objFile in colFiles
attachFile = (objfile.name)
Set objEmail = CreateObject("CDO.Message"
' Assign message properties (To, From, Subject, etc.)
objEmail.From = "Project_Team@cpaw.com"
objEmail.To = "testuser@cpaw"
objEmail.Subject = "Sync email file"
objEmail.Textbody = "Sync files attached"
") = _
' Assign additional message properties, update the object, and send the message
") = 2
") = 25
This needs to be done twice per day. I'm currently running it as a scheduled task on a Windows XP (SP1) box. It works fine as long as the user (Local admin) account is logged in. Once logged off the scheduled task fails and the following error is recorded in the event log:
Event Type: Error
Event Source: DCOM
Event Category: None
Event ID: 10002
Time: 3:45:02 PM
User: NT AUTHORITY\SYSTEM
Access denied attempting to launch a DCOM Server. The server is:
The user is SYSTEM/NT AUTHORITY, SID=S-1-5-18.
The server 05D1D5D8-18D1-4B83-85ED-A0
} shows in the registry as CCM WMI Event Provider. I imagine it's a permissions issue with the WMI service or DCOM. I've tried changing some permissions for both but nothing has worked so far. Ideas?