Solved

vbs script to write to application log file

Posted on 2004-08-05
3
1,547 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
In this article, I will show you HOW TO: Suppress Configuration Issues and Warnings Alert displayed in Summary status for ESXi 6.5 after enabling SSH or ESXi Shell.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

762 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now