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
shyam pothiniAsked:
Who is Participating?
 
Bill PrewCommented:
The general idea would be:

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" (
    REG ADD "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" /V "My App" /t REG_SZ /F /D "C:\MyAppPath\MyApp64.exe"
) else (
    REG ADD "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" /V "My App" /t REG_SZ /F /D "C:\MyAppPath\MyApp32.exe"
)

Open in new window


»bp
0
 
Bill PrewCommented:
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
0
 
shyam pothiniAuthor Commented:
Thanks,

I am confused.
I want to add commnd here
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
so how can I do that
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

 
Bill PrewCommented:
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
0
 
shyam pothiniAuthor Commented:
thanks

it didn't work
batch file ran but it didn't add reg key
0
 
shyam pothiniAuthor Commented:
yes I know how to add the reg keys in batch file
0
 
Bill PrewCommented:
You ran it with elevated privileges, yes?

What errors or output did you get?

What was your final BAT script?


»bp
0
 
shyam pothiniAuthor Commented:
it worked thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.