Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8550327
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T13:55:34+00:00 2026-06-11T13:55:34+00:00

I am writing a script that find a registry value and returns that value

  • 0

I am writing a script that find a registry value and returns that value to the windows command prompt screen and also adds that to a .txt file. I am to a point where I need to also test to see if the machine is 32 bit or 64 bit so that I know which command to use to find the value I need in the registry.

I am looking for logic along the lines of what I have written below:

If 32 bit then (run this command)
else
(run this command)

I am hoping to not have to have any text files or anything else required for this script to work. Below is the code I have so far. Due to the registry location being private, I changed the location to a made up location. (Note: I do have a text file this script reads from that I insert the names of computers and servers. So far the code I have works but with 2 registry find commands I am obviously not getting right results when its checking a 32 bit machine for a 64 bit registry location)

@echo off

Setlocal

::sets the ldt variable to the local date and time in yyyymmdd_hhmmss
for /f "skip=1" %%c in ('wmic os get LocalDateTime') do set ldt=%%c
set ldt=%ldt:~0,8%_%ldt:~8,6%


::searches for computer names in servers.txt and then calls server sub routine. Once it goes back to the for loop it moves onto the next line in servers.txt
for /f %%c in (servers.txt) do (
set server=%%c
call:server
)
pause
goto:eof

--------------------------------------------------------------------
:server
set stamp=%date% at %time%
set DateTime=%stamp%

::Tests for a good ping, if no ping then move onto next machine
ping -n 1 -w 250 %server% > nul 
if %errorlevel% NEQ 0 (
  ECHO No Ping on %server%
  ECHO No Ping on %server% >>AuditScript_%ldt%.txt
  goto:eof
)
call:screen
call:log
goto:eof

--------------------------------------------------------------------
:screen
echo.
echo Computer name: %server%
reg query "\\%server%\HKLM\SOFTWARE\Registry Folder1\Information\" /V "Datavalue" | FIND "Datavalue"
reg query "\\%server%\HKLM\SOFTWARE\Wow6432Node\Registry Folder1\Information" /V "Datavalue" | FIND "Datavalue"
echo.
goto:eof

--------------------------------------------------------------------
:log
echo. >>AuditScript_%ldt%.txt
echo Registry value for %server% on %stamp% >>AuditScript_%ldt%.txt
reg query "\\%server%\HKLM\SOFTWARE\Registry Folder1\Information\" /V "Datavalue" | FIND "Datavalue" >>AuditScript_%ldt%.txt
reg query "\\%server%\HKLM\SOFTWARE\Wow6432Node\Registry Folder1\Information" /V "Datavalue" | FIND "Datavalue" >>AuditScript_%ldt%.txt
echo. >>AuditScript_%ldt%.txt
goto:eof

--------------------------------------------------------------------
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T13:55:35+00:00Added an answer on June 11, 2026 at 1:55 pm
    FOR /F "tokens=3" %%x in ('reg query "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /V PROCESSOR_ARCHITECTURE') do set CPU=%%x
    echo CPU Architecture: %CPU%
    if "%CPU:~-2%"=="64" (
      echo Do This
    ) else (
      echo Do That
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a Perl script (in Windows) that is using File::Find to index
I'm writing a shell script that opens a file and needs to find a
I'm writing a script that parses the pure-ftpwho -s command to get a list
I am writing a script that is retrieving information from file places.sqlite (history) and
I have recently finished writing a script for Maya that exports a file containing
I'm currently writing a building script that needs the installdir registry key for visual
I am writing a Perl script that is iterating over file names in a
I'm writing a script that parses an XML file and displays it in html.
I'm writing a WIX script. I have a custom-action that adds rows dynamically to
I'm in the process of writing a script that chunks a large CSV file

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.