| View previous topic :: View next topic |
| Author |
Message |
h4c0r-BG Master Cheater
Reputation: 0
Joined: 29 Nov 2006 Posts: 449 Location: The yogurt country
|
Posted: Tue Oct 14, 2008 3:33 am Post subject: [Delphi] Allow a program to FireWall |
|
|
Let's say i have a program made in delphi with 1 button.
On that button i have CreateProcess(); to another application.
When the other application is started Windows Firewall pops up and asks me to block/unblock/ask me later etc..
So i want to ask what is the best way to use the following code:
netsh firewall add allowedprogram C:\MyApp\MyApp.exe "My Application" ENABLE
and i do not want to call cmd.exe and type this in it ...
Information about firewall taken from: http://support.microsoft.com/kb/947709
_________________
|
|
| Back to top |
|
 |
tombana Master Cheater
Reputation: 2
Joined: 14 Jun 2007 Posts: 456 Location: The Netherlands
|
Posted: Tue Oct 14, 2008 8:41 am Post subject: |
|
|
One way to do it would be the following, although when you use this the user might still see the cmd window in a split second:
netsh is an application, so you can open it with createprocess, and use those arguments as command line.
It'll be something like:
| Code: | | CreateProcess("netsh", "netsh firewall add allowedprogram C:\MyApp\MyApp.exe \"My Application\" ENABLE", other arguments...) |
I don't know if netsh has some sort of 'silent' command line switch to disable the showing of the cmd window or disable any user notifications. Type 'netsh /?' or something to find out.
|
|
| Back to top |
|
 |
smartz993 I post too much
Reputation: 2
Joined: 20 Jun 2006 Posts: 2013 Location: USA
|
Posted: Tue Oct 14, 2008 8:47 am Post subject: |
|
|
| Code: |
var
command, parameter : String;
begin
command := 'netsh';
parameter := 'firewall add allowedprogram C:\MyApp\MyApp.exe "My Application" ENABLE';
ShellExecute(Handle, 'open', pchar(command), pchar(parameter), nil, SW_SHOWNORMAL);
end;
|
Of course, add ShellAPI to your uses list to be able to use the ShellCommands. Also, the last parameter of ShellExecute, should be able to be changed so no window will pop up.
|
|
| Back to top |
|
 |
|