Solved

vbs script to write to application log file

Posted on 2004-08-05
3
1,549 Views
Last Modified: 2010-04-14
I have some vbs scripts, actually windows script host stuff.  I ask for a vbs script that writes a message to the applicaton log file, that is, that which is viewed by the event viewer.  I will then integrate that into my existing vbs scripts.
0
Comment
Question by:astar666
3 Comments
 
LVL 9

Expert Comment

by:jdeclue
ID: 11729777
Here is a link to code snippets and examples for writing to the event log with Visual Basic. Watch out for the pop-ups.


http://kandkconsulting.tripod.com/VB/VBCode.htm
0
 

Author Comment

by:astar666
ID: 11730318
I do not have visual basic on my machine, but I search around on the web page to find the code you referenced, thinking it might provide a clue.  I did not find it.  For completeness, here is an example vbs script which I want to write to the application event log file.

set WshShell = CreateObject("WScript.Shell")
WshShell.Run "%SystemRoot%\System32\cleanmgr.exe"
WScript.Sleep 2000

WshShell.SendKeys "{ENTER}"
wscript.sleep 1000

While WshShell.AppActivate("Disk Cleanup for")= FALSE
  wscript.sleep 5000
Wend

wscript.sleep 1000
WshShell.SendKeys "{ENTER}"

wscript.sleep 1000
WshShell.SendKeys "{ENTER}"

While WshShell.AppActivate("Disk Cleanup for")= FALSE
      wscript.sleep 5000
Wend
0
 
LVL 16

Accepted Solution

by:
mdiglio earned 125 total points
ID: 11731496
Hello,
From the MS Website here is a script that will write to the application event log file
of the local machine

Const EVENT_SUCCESS = 0
Set objShell = Wscript.CreateObject("Wscript.Shell")
objShell.LogEvent EVENT_SUCCESS, _
    "Payroll application successfully installed."


to write to the application event log file on a remote machine:

Const EVENT_SUCCESS = 0
Set objShell = Wscript.CreateObject("Wscript.Shell")
objShell.LogEvent EVENT_SUCCESS, _
    "Payroll application successfully installed." , "\\PrimaryServer"

Good Luck!
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
This article outlines the process to identify and resolve account lockout in an Active Directory environment.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question