'********************************************************
'* Windows Script Source Code *
'*Used for Collect PPG China Site infromation ==> Audit *
'*Author: Fu Eric eric.fu@hm.com *
'*HM SITE Admin *
'*Date: 12 Oct 2013 *
'*Any Site can change infor depend on your request *
'********************************************************
On Error Resume Next
Dim ClickValue
Const HKEY_CLASSES_ROOT = &H80000000 'HKCR
Const HKEY_CURRENT_USER = &H80000001 'HKCU
Const HKEY_LOCAL_MACHINE = &H80000002 'HKLM
Const HKEY_Users = &H80000003 'HKU
Const HKEY_Current_Config = &H80000005 'HKCC
Const REG_SZ = 1
Const REG_EXPAND_SZ = 2
Const REG_BINARY = 3
Const REG_DWORD = 4
Const REG_MULTI_SZ = 7
Const KEY_QUERY_VALUE = &H0001
Const KEY_SET_VALUE = &H0002
Const KEY_CREATE_SUB_KEY = &H0004
Const DELETE = &H00010000
'''-----------------file path ----------------------------------------
strComputer = "."
Set WshShell = WScript.CreateObject("WScript.Shell")
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
strKeyRoot = HKEY_CURRENT_USER
Regpath = "HKEY_CURRENT_USER"
strKeyPath = "Software\Policies\Microsoft\office\14.0\outlook\cached mode"
oReg.EnumValues strKeyRoot, strKeyPath, arrValueNames, arrValueTypes
For i=0 To UBound(arrValueNames)
If arrValueNames(i) = "Enable" Then
oReg.GetDWORDValue strKeyRoot, strKeyPath, arrValueNames(i), strRunCommand
if strRunCommand = 1 then
WshSHell.popup "Information: "& vbcrlf _
& "===============================================" & vbcrlf & "Outlook Cache mode Enabled, You Can shutdown computer tonight! Thanks for using!" & vbcrlf & "===============================================" _
, 30, "Developed By CN IT", 0 + 64
else
WshSHell.popup "Information: "& vbcrlf _
& "===============================================" & vbcrlf & "Outlook Cache mode Disabled, Don't Shutdown computer tonight with Outlook closed!" & vbcrlf & "===============================================" _
, 30, "Developed By CN IT", 0 + 64
ClickValue = MsgBox ("Do you want to CLOSE OUTLOOK Now ? ", 65, "Develop by CNIT")
if ClickValue = 1 then
Set objWMIService =GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
Set colProcessList=objWMIService.ExecQuery _
("Select * from Win32_Process Where Name='outlook.exe'")
For Each objProcess in colProcessList
objProcess.Terminate()
Next
else
wscript.echo "Click Cancel By User"
end if
end if
End If
Next
本文转自 bilinyee博客,原文链接: http://blog.51cto.com/ericfu/1358791 如需转载请自行联系原作者