Solved

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

Posted on 2007-04-09
6
547 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Determine if SQL is installed in Server 2008 R2 4 117
Looking for a program that deletes all files of same size 18 89
how to export this list 4 84
Powershell GUI 11 66
Have you ever had a hard drive that you can't boot into, but need to change the registry? Here is the solution! This article guides you through accessing and editing a registry of a non-primary drive. To read registry information on a non-prim…
I hope you'll find this tutorial useful and interesting. So let's try to extend Tcl with a new package.  For anyone more deeply interested please check out the book "Practical Programming in Tcl and Tk". It's really one of the best written books abo…
This video Micro Tutorial explains how to clone a hard drive using a commercial software product for Windows systems called Casper from Future Systems Solutions (FSS). Cloning makes an exact, complete copy of one hard disk drive (HDD) onto another d…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

730 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