Solved

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

Posted on 2007-04-09
6
548 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 81

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

Industry Leaders: 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

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 article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …
Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…

717 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