Solved How to update batch file with registry key value

October 16, 2017 at 23:15:43
Specs: Windows 10
Hi,

I would like to know how to update a batch file with the value from registry key so as to subsequently add files to the folder.

Eg:
I have the below value from registry.

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\SolidWorks\IM]
"InstallDir 2017"="C:\\Program Files\\SOLIDWORKS Corp 2017"

What will be the code to extract info from "InstallDir 2017" and place files at "C:\\Program Files\\SOLIDWORKS Corp 2017"

Thanks.
Swamiadiyan.K


See More: How to update batch file with registry key value

Reply ↓  Report •

✔ Best Answer
October 21, 2017 at 08:47:42
::====== script starts here ===============
::
:: get.bat 2017-10-21 22:36:17.39
@echo off & setLocal enableDELAYedeXpansioN

:main
for /f "tokens=* delims= " %%a in ('find "InstallDir" ^< myfile') do (
call :sub1 %%a
)
set
goto :eof

:sub1
set _Path=%2
)
goto :eof
::====== script ends here =================

=====================

M2 Get custom script or take private lessons



#1
October 17, 2017 at 15:59:10
That registry extract appears to indicate the install directory for the Solidworks program, which is C:\Program Files\solidworks Corp 2017.

I don't therefore understand what you are trying to do.

Always pop back and let us know the outcome - thanks


Reply ↓  Report •

#2
October 20, 2017 at 08:27:04
Not clear. Please try again.
2017-10-20 22:25:01.50 GMT +7

=====================

M2 Get custom script or take private lessons


Reply ↓  Report •

#3
October 21, 2017 at 05:20:11
Sorry for confusing.

My intention was to achieve the below in the batch file:

@Echo On
Set _Path=C:\Program Files\SOLIDWORKS Corp 2017\SOLIDWORKS\data\taskpane\SOLIDWORKS resources
Set _FileName=swresources.html
copy /y "%~dp0swresources.html" "%_Path%"
copy /y "%~dp0My-logo_high res.png" "%_Path%\images"
copy /y "%~dp0Linkedin-14px.png" "%_Path%\images"
pause

The challenge is sometimes when people install the software they may change the installation location at that time this batch file will not work.

So i wanted to extract the installation location from registry which i earlier posted and use it so if anybody else installing anywhere also this customisation will work.


Reply ↓  Report •

Related Solutions

#4
October 21, 2017 at 08:47:42
✔ Best Answer
::====== script starts here ===============
::
:: get.bat 2017-10-21 22:36:17.39
@echo off & setLocal enableDELAYedeXpansioN

:main
for /f "tokens=* delims= " %%a in ('find "InstallDir" ^< myfile') do (
call :sub1 %%a
)
set
goto :eof

:sub1
set _Path=%2
)
goto :eof
::====== script ends here =================

=====================

M2 Get custom script or take private lessons


Reply ↓  Report •

Ask Question