No announcement yet.

Registry script

  • Filter
  • Time
  • Show
Clear All
new posts

  • Registry script

    Could someone post or send me an example of a batchfile or vbscript that looks at a particular registry setting and returns what it is set at?
    I need to get what a bunch of driver versions are, I know the key, I just nee a way to get the info in to a text file so IO can import it into an excel spreadsheet.

    Cheers o_O

  • #2
    Re: Registry script

    Have you tried REG.EXE ?
    reg query /?
    will give you more details/examples
    Guy Teverovsky
    "Smith & Wesson - the original point and click interface"


    • #3
      Re: Registry script

      Yes this will return the values, but it does not output to text. It is n fact the way I am doing it now, with a perl script to remove all the extra text and then I can use it. I am trying to remove the extra step and just have the data sent to text.


      • #4
        Re: Registry script

        all you gotta do to put it in a text file in a batch script is redirect it to file so do

        reg query regkey > C:\file.txt

        the > "filename" will work with any command it will redirect to output on your screen to a file you can use a unc or mapped drive in the path as well to redirect to a server. use >> to append that data meaning just add it to the end of the file and dont overwrite the whole file.
        MCSE 2000\2003, A+


        • #5
          Re: Registry script

          Yes! That is absolutely correct! But the output is everything, and not just the value of the Key. I am after a driver version of a particular piece of software.
          I know the key, what I am looking for is a batchfile or vbscript that looks at a particular registry setting and returns what it is set at. I guess I needed to be more specific that I only want the value returned to a text file.

          Thanks to all of you that are thinking about it.


          • #6
            Re: Registry script

            reg query keyname /v valuename > filename.txt

            so for example

            reg query hkcu\powercfg /v currentpowerpolicy > C:\file.txt

            this will put in it a tab seperated value text file. open that in excel and delete the first 2 rows which have the key names and the type. otherwise your have to do a vb script.
            MCSE 2000\2003, A+


            • #7
              Re: Registry script

              That is a viable method to accomlish this, should there be up to maybe 20 servers and then it gets pretty tedious. In my case it is over 1000 servers I need to do this on. So hence my looking for a sctiptable method to get these values, without extraneous data or spaces, all in one text file.

              Thanks Again!


              • #8
                Re: Registry script

                sound more for a topic in the scripting forum..

                but ok,

                in that case you need to provide some more info..

                do you have a list of servers in a text file? seperated with an enter?
                (to read out the server)


                a script who loops that text file until end of file, and querying the regkey
                you can start there.

                YOu will create something like this:

                begin script
                Set Global variables like Keys and so on..
                Open Server Text file for reading
                Open RegKey Text file for Appending

                While not end of file do
                Servername = Readline (number)
                number = number +1
                on error resume next
                If servername <> "" then

                Set WMI Variable
                Declare local variable.

                Regread Var 1 = regkey declared.
                Regread Var 2 = regkey declared.
                Regread Var 3 = regkey declared.

                Write to textfile servername, var 1, var2 ,var 3
                Write to textfile Blankline
                end if

                just an idea how to write it..
                does this help??
                Technical Consultant

                MCITP(EA, SA), MCSA/E 2003:Security, CCNA, SNAF, DCUCI, CCSA/E/E+ (R60), VCP4/5, NCDA, NCIE - SAN, NCIE - BR, EMCPE
                "No matter how secure, there is always the human factor."

                "Enjoy life today, tomorrow may never come."
                "If you're going through hell, keep going. ~Winston Churchill"