Batch file to write to the services file

I need to but an exception into the services file which I need to roll out to every pc on my network. The port number is 2503/tcp I know that is has to be in order for it to work.  I would like to be able to write a batch file to do this.
skdcsupportAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

BarthaxCommented:
It is easiest through a GPO: edit the Computer Configuration\Administrative Templates\Network\Network Connections\Windows Firewall\Domain Profile - the Windows Firewall: Define port exceptions setting & set the exception to:

2503:TCP:*:enabled:<your description here>

As you've asked for a batch file, set up a .reg file and a batch file with:

regiedt.exe /s <full UNC path to .reg file>

With the .reg file having content as attached.
Windows Registry Editor Version 5.00
 
[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\WindowsFirewall\DomainProfile\GloballyOpenPorts\List]
"2503:TCP:*:enabled:<your description>"="2503:TCP:*:enabled:<your description>"

Open in new window

0
skdcsupportAuthor Commented:
I think I wasn't clear in what I need.

I need to edit the services file c:\windows\systems32\drivers\etc\services

I need to but an exception in of Eureka 2503/tcp

I have attached a screen shot of where I need the exception  

eureka.JPG
0
BarthaxCommented:
Ah, I see.  You could have a sample services file which your batch file simply copies across - this would ensure all of the machines have the same services configuration.  In terms of altering the file, the addition of the line is simple enough with a:

echo "eureka\t2053/tcp" >> %SYSTEMROOT%\system32\drivers\etc\services

Unfortunately, I can't help you with checking the file to see if it already exists in there. :(
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

BarthaxCommented:
Errata: the "eureka\t2053/tcp" was meant to be explained: when you are creating the batch file, make sure you use a tab character instead of the "\t" after eureka. :)
0
skdcsupportAuthor Commented:
Thanks a lot worked a treat.
0
BarthaxCommented:
Good to hear, thanks for confirming. :)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Batch

From novice to tech pro — start learning today.