Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help writing to the system log

Status
Not open for further replies.

kmcferrin

MIS
Jul 14, 2003
2,938
0
0
US
Does anyone know how to write an event to the System log in Windows? I've found tons of code that writes events to the Application log, but I can't find anything about writing to the system log. The WshShell.LogEvent method doesn't seem to support this, and I can't find any other way of writing to the event logs.

I'm guessing that you can only write to the Application log from within scripts, but I'm hoping that's not the case. Any help would be appreciated.
 
Have you tried to play with the EVENTCREATE command line utility ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I don't beleive it is possible via script. You can however create a custom event log.

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Looks like you could script eventcreate since it has command line switches.

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Okay guys, I can't seem to create a custom log in the eventlog no matter what method I use.

I have tried this:

Const NO_VALUE = Empty

Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.RegWrite _
"HKLM\System\CurrentControlSet\Services\EventLog\Scripts\", NO_VALUE

As well as:

Set WshShell = WScript.CreateObject("WScript.Shell")

strCommand = "eventcreate /T Error /ID 100 /L Scripts /D " & _
Chr(34) & "Test event." & Chr(34)
WshShell.Run strcommand

Neither one works. I can write to the application log however. Is this a permissions thing? Does Windows have the eventlog locked down?
 
The following code SHOULD create a new log called Scripts

Code:
Const NO_VALUE = Empty

Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.RegWrite _
    "HKLM\System\CurrentControlSet\Services\EventLog\Scripts\", NO_VALUE

If it is not creating the log file then use Regedt32 and verify the permissions on the "HKLM\System\CurrentControlSet\Services\EventLog" registry key. The account you are running the script from needs to have Full Permission.

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top