Avatar of shyam pothini
shyam pothini
 asked on

creating a batchfile

hello all

I am trying to create a batch file to add registry key.
its should run on both 32bit and 64 bit
there are 2 different registry keys for 32bit and 64bit.
so if it is 32-bit, it adds the 32-bit registry key and vice versa

Any ideas?

Thanks in advance
Windows BatchWindows OS

Avatar of undefined
Last Comment
shyam pothini

8/22/2022 - Mon
Bill Prew

Give this a try.

for /f "skip=2 tokens=2-5 delims=," %%A in ('wmic os get osarchitecture^,version /format:csv') do set arch=%%A
if "%arch%" EQU "64-bit" (
    rem do 64 bit logic here
) else (
    rem do 32 bit logic here
)

Open in new window


»bp
shyam pothini

ASKER
Thanks,

I am confused.
I want to add commnd here
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
so how can I do that
Bill Prew

Based on your question I thought you knew how to add to the registry from batch, and were just looking for help differentiating between 32 and 64 bits.

If you want the exact registry commands, then I would need to know the key and value you want to add for both 32 and 64 bit.


»bp
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
ASKER CERTIFIED SOLUTION
Bill Prew

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
shyam pothini

ASKER
thanks

it didn't work
batch file ran but it didn't add reg key
shyam pothini

ASKER
yes I know how to add the reg keys in batch file
Bill Prew

You ran it with elevated privileges, yes?

What errors or output did you get?

What was your final BAT script?


»bp
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
shyam pothini

ASKER
it worked thanks