Click here to Skip to main content
12,952,792 members (35,181 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Hello everybody.

I have write Window Service follow at reference : Simple Windows Service Sample[^]

Now , i want to block a application or port on window such as : Block Port 123, Block program notepad.exe . I think it`s write in Service Onstart event

Protected Overrides Sub OnStart(ByVal args() As String)
        'Block Port on Window
         'Block application on window , Example Block notepad.exe
    End Sub

Do you help me about this topic or reference link for me.

Thank you.
Posted 18-Jun-12 7:04am
Updated 18-Jun-12 7:20am
Nelek 18-Jun-12 13:21pm
Edit: clickable link
headshot9x 18-Jun-12 23:43pm
Hi Dave Kreskowiak
I have read your link, as it, in OnStart methos, we do what to do, as in this, of course Notepad window, for example, to find its path, and then lock it
Example Notepad :

Target : %windir%\system32\notepad.exe

Protected Overrides Sub OnStart(ByVal args() As String)

'Block Port on Window
' I dont`t known

'Block application on window , Example Block notepad.exe
' Get GetCommandLineArgs Notepad
' Then change Registry of them

End Sub

If there is something wrong you can tell me
Thank you

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

This is called a firewall you're attempting to write. Unless you know the Windows network stack, you'll find this extremely difficult to implement.

For testing, you could pass this information in through the services OnStart method arguments. It works just like you wrote. The arguments would be passed in as a couple of strings in an array.[^]

For a production application, a firewall config is usually stored somewhere else, like an encrypted entry in the Registry or a config file.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month
OriginalGriff 6,389
CHill60 3,490
Maciej Los 3,103
Jochen Arndt 1,975
ppolymorphe 1,920

Advertise | Privacy | Mobile
Web01 | 2.8.170525.1 | Last Updated 18 Jun 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100