2011-09-23 4 views

답변

8

:

Set shell = CreateObject("WScript.Shell") 
shell.LogEvent 4, "Your Message Here" 

4 심각도 레벨이다. MSDN에서 LogEvent 방법에 대해 자세히 알아볼 수 있습니다.

+0

도와 주셔서 감사합니다. 로그 기록은 어디에서 할 수 있습니까? 나는 그것을 찾지 못한다 – Emree

+0

@Emree - 이벤트 뷰어에 써야한다. 실행 대화 상자에서'compmgmt.msc'를 실행하면 알 수 있습니다. Google에서 이벤트 뷰어를 살펴보십시오. – vcsjones

1

이것은 오래되었지만 여전히 유효합니다.

http://msdn.microsoft.com/en-us/library/b4ce6by3

은 또한 이벤트 로그 그래서 당신은 수도 있고 내 액세스 할 수 없습니다 스크립트를 실행하는 사용자에 따라에 쓸 수있는 권한이 필요합니다. 그래서 추천

+0

과 체크 아웃 내 링크는 도움을 주셔서 감사합니다. 로그 기록은 어디에서 할 수 있습니까? 찾지 못했습니다 – Emree

1

자신의 로그 파일에 간단하게 쓸 수 있습니다.

자세한 내용 및 세부 http://www.yeshaib.com/2010/08/vbscript-in-the-logging/

'---------------------------------------------------------------------- 
' 
' Please Enter Updates with date and name including line of Change 
'---------------------------------------------------------------------- 
'---------------------------------------------------------------------- 

set objShell = CreateObject("Wscript.Shell") 
set objFSO = CreateObject("Scripting.FileSystemObject") 

'--- Main Begins --------------------------------------- 

WriteToLog("Generic Log.vbs - Write This") 

'--- Main Ends ----------------------------------------- 

'--- Write to log -------------------------------------- 
Sub WriteToLog(strLogMessage) 
Const ForAppending = 8 
Const vbsName = "Generic Log" 

strLogFileName = "C:\GenericLog.log" 
strLogEntryTime = NOW 

'test whether file exists To either write/append to file 
if objFSO.FileExists(strLogFileName) Then 
Set objLogFileTransaction = objFSO.OpenTextFile(strLogFileName, ForAppending) 
Else 
Set objLogFileTransaction = objFSO.CreateTextFile(strLogFileName) 
End if 

objLogFileTransaction.WriteLine strLogEntryTime & chr(9) & chr(58) & chr(9) & vbsName & chr(9) & chr(58) & chr(9) & strLogMessage 
objLogFileTransaction.Close 
WScript.StdOut.WriteLine strLogMessage 
WScript.StdOut.WriteLine "" 
End Sub 
관련 문제