I have a script to resize event logs on PC's as they log on. However, it errors when the user isn't a local admin.
Here is the script:
**************************************
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate,(Security)}!\\" & _
strComputer & "\root\cimv2")
Set colLogFiles = objWMIService.ExecQuery _
("Select * from Win32_NTEventLogFile")
For each objLogfile in colLogFiles
strLogFileName = objLogfile.Name
Set wmiSWbemObject = GetObject _
("winmgmts:{impersonationLevel=Impersonate}!\\.\root\cimv2:" _
& "Win32_NTEventlogFile.Name='" & strLogFileName & "'")
wmiSWbemObject.MaxFileSize = 10000000
wmiSWbemObject.OverwriteOutdated = 7
wmiSWbemObject.Put_
Next
******************************************
Is there any way to pass credentials that will allow this to run? The crucial part for me is the line that resizes the log.
I am running this as a .vbs file called from the login script.
Thank you,
Dan
Here is the script:
**************************************
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate,(Security)}!\\" & _
strComputer & "\root\cimv2")
Set colLogFiles = objWMIService.ExecQuery _
("Select * from Win32_NTEventLogFile")
For each objLogfile in colLogFiles
strLogFileName = objLogfile.Name
Set wmiSWbemObject = GetObject _
("winmgmts:{impersonationLevel=Impersonate}!\\.\root\cimv2:" _
& "Win32_NTEventlogFile.Name='" & strLogFileName & "'")
wmiSWbemObject.MaxFileSize = 10000000
wmiSWbemObject.OverwriteOutdated = 7
wmiSWbemObject.Put_
Next
******************************************
Is there any way to pass credentials that will allow this to run? The crucial part for me is the line that resizes the log.
I am running this as a .vbs file called from the login script.
Thank you,
Dan