Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 378
  • Last Modified:

Batch File Question

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
lofiched
Asked:
lofiched
  • 5
  • 3
1 Solution
 
KavarCommented:
several, you specified batch, are you stuck on this (its easier outside of batch)
0
 
lofichedAuthor Commented:
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
 
lofichedAuthor Commented:
oh, yeah, and it needs to be able to run from the logon script in an NT environment.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
KavarCommented:
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
 
lofichedAuthor Commented:
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
 
lofichedAuthor Commented:
sorry, NOT creating more files than necessary
0
 
KavarCommented:
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
 
lofichedAuthor Commented:
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now