Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# VB.NET service Window
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
Edited 18-Jun-12 7:20am
Nelek51.7K
v2
Comments
Nelek at 18-Jun-12 13:21pm
   
Edit: clickable link
headshot9x at 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
Start in : %HOMEDRIVE%%HOMEPATH%

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
good
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.
  Permalink  
v2

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 6,805
1 OriginalGriff 6,696
2 CPallini 5,350
3 George Jonsson 3,609
4 Gihan Liyanage 2,792


Advertise | Privacy | Mobile
Web03 | 2.8.140922.1 | Last Updated 18 Jun 2012
Copyright © CodeProject, 1999-2014
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