Solved

how to create a batch file that adds the registry values and deletes itself?

Posted on 2007-04-09
6
546 Views
Last Modified: 2010-03-05
Hi, i am system admin for a small distributed network. i want to put the netcat in the windows but as my network is distributed it would take time , what i have thought to put the netcat in systems and remove the shared drives. so can you please tell me how can i add a batch file to system start up folder that it adds the netcat registry value to registry automatically without interaction and deletes it self with out adding registry key every time and bothering the users when the system reboots?is there any alternative solution to this please, if batch file is not a good idea?
0
Comment
Question by:shairankhan
  • 3
6 Comments
 
LVL 9

Accepted Solution

by:
herbus earned 125 total points
ID: 18875596
If I understand right, you want the batch file to be deleted after it's been run so that it doesn't keep adding the registry value, yah?

For one, it won't matter if it runs multiple times - it will just overwrite the entry each time, but it will overwrite it with the same settings, so no problem?  Best to run this from a network location, ie: via group policy, rather than having local scripts to deploy...

If for whatever reason you don't want it to run if the registry key is already in there, then I'd suggest an easy way would be to incorporate some sort of logging into the script... even if all it does is make a folder somewhere (like c:\temp\...), then when the script runs it will check for that folder - if it exists the script will quit, if not then it will add the registry values and create the folder...

ie: a simple batch file would do the log check and call on a vbs script if the registry values need to be added - example batch file below:

if exist "%userprofile%\Local Settings\Temp\regadd.log" goto end
cscript \\domaincontroller\netlogon\AddRegistryValues.vbs
md "%userprofile%\Local Settings\Temp\regadd.log"
:end

the vbs file would obviously contain the reg additions you need... ala http://www.microsoft.com/technet/scriptcenter/scripts/os/registry/osrgvb02.mspx?mfr=true

Hope this helps,
Herb
0
 
LVL 9

Expert Comment

by:herbus
ID: 18875614
Keep in mind that the example I posted had %userprofile% variable paths, which would apply to a user login script, not a computer startup script... I'd copied it from one I use at work and forgot to change that bit... if it's a computer startup script you'd replace it with "c:\temp\regadd.log" or whatever...

...and of course you'll want to test it before deploying it network-wide via a policy or such...

Cheers,
Herb
0
 
LVL 80

Expert Comment

by:David Johnson, CD, MVP
ID: 18884691
Rather than coding in hard values you can use system variables %temp% instead of c:\documents and settings\%userprofile% ..
0
 
LVL 9

Expert Comment

by:herbus
ID: 19246774
G'day LeeTutor & folks,.. the recommendations for cleanup are normally spot on, but in this case I'm confident that the solution I posted is valid.  If there's no objection I'd put my hand up to claim this as answered...

Cheers,
Herb
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Many admins will agree: WSUS is is a nice invention but using it on the client side when updating a newly installed computer is still time consuming as you have to do several reboots and furthermore, the procedure of installing updates, rebooting an…
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

789 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