Batch file to write to the services file

Posted on 2008-02-11
Medium Priority
Last Modified: 2011-10-19
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.
Question by:skdcsupport
  • 4
  • 2
LVL 19

Expert Comment

ID: 20866857
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
"2503:TCP:*:enabled:<your description>"="2503:TCP:*:enabled:<your description>"

Open in new window


Author Comment

ID: 20873537
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  

LVL 19

Accepted Solution

Barthax earned 2000 total points
ID: 20873578
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. :(
Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

LVL 19

Assisted Solution

Barthax earned 2000 total points
ID: 20873586
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. :)

Author Comment

ID: 20883084
Thanks a lot worked a treat.
LVL 19

Expert Comment

ID: 20887148
Good to hear, thanks for confirming. :)

Featured Post

[Webinar] Improve your customer journey

A positive customer journey is important in attracting and retaining business. To improve this experience, you can use Google Maps APIs to increase checkout conversions, boost user engagement, and optimize order fulfillment. Learn how in this webinar presented by Dito.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
When you receive another warning that your shared drive is almost full and you have asked your users to clean out old files again and again, here is a single command that may help. This command will place all the files that have not been used rec…
There may be issues when you are trying to access Outlook or send & receive emails or due to Outlook crash which leads to corrupt or damaged PST file. To eliminate the corruption from your PST file, you need to repair the corrupt Outlook PST file. U…
In this video I will demonstrate how to set up Nine, which I now consider the best alternative email app to Touchdown.
Suggested Courses

594 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question