473,657 Members | 2,733 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to create a Service to Log Application Names

Hi,

I'm a total newbie at VB.NET so please bare with me. I would like to
create a simple service that will log all exe and com files that are
executed but I don't know where to start.

I'm pretty sure I know how to create a Windows Service using VB.NET
2003. However, I am stuck on the next part. When a user runs an
application I would like to create a text file that logs the EXE or COM
file name that has been executed. The text file is a single file and
each entry of EXE or COM will be date/time stamped.

How do I capture the EXE or COM file name that has been run by the
user?

Can someone point me in the right direction?

Thanks.

Mar 6 '06 #1
3 1535
Hi,

I have not tried this in a windows service but you can use the wmi
to be notified when an application is started. It appears that if you list
the running process with the wmi the last one on the list is the one that
just started. You need to add a reference to system.manageme nt. Hope this
helps.

Imports System.Manageme nt

Public Class Form1
Dim WithEvents w As ManagementEvent Watcher
Dim q As WqlEventQuery
Delegate Sub LoadList()

Private Sub Form1_FormClosi ng(ByVal sender As Object, ByVal e As
System.Windows. Forms.FormClosi ngEventArgs) Handles Me.FormClosing
w.Stop()
End Sub

Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
Try
q = New WqlEventQuery
q.QueryString = "SELECT * FROM" & _
" __InstanceCreat ionEvent WITHIN 1 " & _
"WHERE TargetInstance isa ""Win32_Process """
w = New ManagementEvent Watcher(q)
w.Start()
Catch ex As Exception
Trace.WriteLine (ex.ToString)
End Try
LoadDriveList()
End Sub

Private Sub LoadDriveList()
ListBox1.Items. Clear()
Dim moReturn As Management.Mana gementObjectCol lection
Dim moSearch As Management.Mana gementObjectSea rcher
Dim mo As Management.Mana gementObject

moSearch = New Management.Mana gementObjectSea rcher("Select * from
Win32_Process")

moReturn = moSearch.Get
For Each mo In moReturn
ListBox1.Items. Add(mo("Name"). ToString)
Next

End Sub

Private Sub w_EventArrived( ByVal sender As Object, ByVal e As
System.Manageme nt.EventArrived EventArgs) Handles w.EventArrived
For Each p As Process In Process.GetProc esses
Trace.WriteLine (p.MainWindowTi tle)
Next
ListBox1.Invoke (New LoadList(Addres sOf LoadDriveList))
End Sub
End Class
Ken
-----------------------
<ge**********@g mail.com> wrote in message
news:11******** **************@ j33g2000cwa.goo glegroups.com.. .
Hi,

I'm a total newbie at VB.NET so please bare with me. I would like to
create a simple service that will log all exe and com files that are
executed but I don't know where to start.

I'm pretty sure I know how to create a Windows Service using VB.NET
2003. However, I am stuck on the next part. When a user runs an
application I would like to create a text file that logs the EXE or COM
file name that has been executed. The text file is a single file and
each entry of EXE or COM will be date/time stamped.

How do I capture the EXE or COM file name that has been run by the
user?

Can someone point me in the right direction?

Thanks.

Mar 6 '06 #2
Thanks Ken. I get "Namespace or type 'management' for the Imports
'System.managem ent' cannot be found." as an error message.

I'm using VB.Net 2003 with .Net Framework 1.1

Have I missed something here?

Mar 6 '06 #3
Hi,

You need to add a reference to system.manageme nt for the application
to work. Right click on references in the solution explorer and select add
reference

Ken
------------------

"gedm" wrote:
Thanks Ken. I get "Namespace or type 'management' for the Imports
'System.managem ent' cannot be found." as an error message.

I'm using VB.Net 2003 with .Net Framework 1.1

Have I missed something here?

Mar 6 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
1922
by: Mr. B | last post by:
I've an application in which I use to check out the date/time stamp of a data base... and if I find that it has been updated, my application runs and does a particular update. Currently I fire off my application hourly useing the built in XP Scheduler. What I am going to do is to have my application check every minute while it is running as I don't want to have to wait up to a hour for my particular update to happen....
7
8850
by: dog | last post by:
I've seen plenty of articles on this topic but none of them have been able to solve my problem. I am working with an Access 97 database on an NT4.0 machine, which has many Access reports. I want my users to be able to select a report, click on a command button on a form, which will then automatically create the report as a pdf file and save it to the user's machine. I am using Adobe Acrobat (5.0 I think) and have Adobe Distiller as a
1
13536
by: charismatic_evangelist | last post by:
I am trying to write a Windows Service in C# .NET Version 1.1. I followed Microsoft's directions: (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbwlkwalkthroughcreatingwindowsserviceapplication.asp) to the letter and everything worked fine. Then I went into Windows Explorer and changed the name of my files to what I really want....
0
935
by: Demetri | last post by:
I have a solution which has multiple projects. One of the projects is a web service. Another project is a web application. The web application needs to reference the web service. The web application has not had a problem with referencing the exposed web methods and classes in the web service. Prior to today the name spaces and project names in each have been changed a bit for organization sake, this also includes changing of names of the...
3
14910
by: Amjad | last post by:
Hi, I just wrote a test Windows Service that creates a text file on startup (please see my code below). The file is never created. Protected Overrides Sub OnStart(ByVal args() As String) Dim swLog As StreamWriter = File.CreateText("C:\myLog.txt") swLog.WriteLine("My Windows Service has just started.") swLog.Close() : swLog.Flush() End Sub
4
6446
by: cmgarcia17 | last post by:
I have two windows services that I've written: the first is a "Listener Service" that listens for MSMQ Message delivery. The second is a "Watcher Service" that monitors the state of the first. If the "Listener Service" goes down I want the "Watcher Service" to receive a notification and perform a set action. To enable this communication I've written a separate assembly (that both services reference) that exposes two interfaces :...
27
3774
by: max | last post by:
Hello, I am a newbye, and I'm trying to write a simple application. I have five tables with three columns; all tables are identical; I need to change some data in the first table and let VB updates the same data in all other four tables in the right places. I know it would be possible by using the ForeignKeyConstraint object. I have created the tables using the DataSet Visual Tool and I know it doesn't create any ForeignKeyConstraint obj....
4
12427
by: etuncer | last post by:
Hello All, I have Access 2003, and am trying to build a database for my small company. I want to be able to create a word document based on the data entered through a form. the real question is this: can Access create the document and place it as an OLE object to the relevant table? Any help is greatly appreciated. Ricky
4
7909
by: =?Utf-8?B?VGFrdW1p?= | last post by:
I have a ASP.NET web page that calls a web service on a server with IIS installed on it. When it calls the web service, it gives a HTTP status 401 error stating that it is unauthorized to call the web service. After searching the Microsoft Knowledge Base, article ID 811318 describes my exact problem. However, when I try to implement the stated solution, I still receive the same error. Basically if I add the following line of code, it...
0
8825
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8732
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8503
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8605
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6164
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4152
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4304
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1615
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.