Solved

Batch File Question

Posted on 2004-04-02
8
371 Views
Last Modified: 2010-04-17
Ok, this is probably an easy answer, but I'm new to scripting so here goes.

I would like to know the answer one or both of the following questions...

1. Is there a way to look for a specific data string in a specific registry key and then create a file based on wether that data string exists?  eg. search the key "HKEY_LOCAL\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings" for data "sp1" in the String Value called MinorVersion.  Then, if (and only if) the data exists, create a reference file called ie6sp1_installed.txt.

or

2. After exporting that key to a text file called Reg_IESettings.txt, search the text file for the string "sp1" and then create a new text file in the same manner as the above question.

I appreciate any help in this area.

Thanks
0
Comment
Question by:lofiched
  • 5
  • 3
8 Comments
 
LVL 10

Expert Comment

by:Kavar
ID: 10741659
several, you specified batch, are you stuck on this (its easier outside of batch)
0
 

Author Comment

by:lofiched
ID: 10741704
well, i was going with batch because we don't have a lot of software utilities here, but if there's and easier way, without needing a special program to do it, that's fine.
0
 

Author Comment

by:lofiched
ID: 10741714
oh, yeah, and it needs to be able to run from the logon script in an NT environment.
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 10

Expert Comment

by:Kavar
ID: 10741741
the problem is batch CANNOT read the registry, although you can programmatically dump the registry, windows2000 and above dump in unicode, all the batch text handlers don't handle unicode so well...

You have 2 options,

use a script (like vbscript) which can be used as a logon script

or

use reg.exe (commandline utility from the resource kit)

Let me know which way you want to go down.
0
 

Author Comment

by:lofiched
ID: 10741831
well, i guess doing the dump will be fine.  i've already got that portion taken care of using

regedit /e c:\folder\test.txt "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\
CurrentVersion\Internet Settings"

That creates a txt file for me just fine.  

Actually what would be great is if I could search test.txt file for "sp1" and then change the name of that file to reflect the presence of that string.  That way I'm creating more files than what is necessary...not that it really matters that much, but I try to be as efficient as possible.

Hope that helps
0
 

Author Comment

by:lofiched
ID: 10741859
sorry, NOT creating more files than necessary
0
 
LVL 10

Accepted Solution

by:
Kavar earned 100 total points
ID: 10742146
after

regedit /e c:\folder\test.txt "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\
CurrentVersion\Internet Settings"

type c:\test.txt | findstr -i "MinorVersion" | findstr -i "sp1">c:\r.txt
for /f %%a in (c:\r.txt) do <whatever you want to do because this machine has sp1>
del c:\r.txt
0
 

Author Comment

by:lofiched
ID: 10742349
Thanks, that worked great.  Although I took out the <findstr -i "MinorVersion"> because it was looking for either "MinorVersion" or "SP1".  So if SP1 did not exist it would still create the file because MinorVersion existed.  Anyway, works perfectly now.  Thanks for your help.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Best way to export and then import DHCP to a new server? 6 67
File Server NTFS Best practice / ICACLS examples 3 110
Base1 Encode/Decode 3 77
Help with simple script. 8 35
This is an explanation of a simple data model to help parse a JSON feed
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
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 …

777 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