1.

Solve : [Bat]Find path in registry and copy files to this path.?

Answer» HELLO,
Need a batch script. The task is: find in REGISTRY path to the program, copy files (with other extensions) from folder where i have batch file and paste copied files to folder from path .

Possible ?
I hope that was understood. Sorry for my english What is the registry key?Thanks for reply. I'm not sure I understand the question correctly....(translator)

Quote
What is the registry key?
In example :
HKEY_LOCAL_MACHINE\SOFTWARE\7-ZipOn my machine it's

HKEY_CURRENT_USER\Software\7-Zip

Ok, in example can be. (on mine is in this two places )

=====

I try to do this on my own in that way :

Quote
for /f "tokens=3" %a in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\7-Zip" /v Path ^| find /i "REG_SZ"') do CD /D %a

or

Quote
for /f "tokens=3" %a in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\7-Zip" /v Path ^| find /i "REG_SZ"') do set Path=%a

but i dont know how to copy files, or how to refer to correct paths. I find something like that :

Quote
set OLDDIR=%CD%
copy file.1 file.2
chdir /d %OLDDIR% &rem restore current directory
(cmd=%,batch=%%)
But dont know how to, and I'm probably wrong ...1. Do not use Path as a variable name. This name is already USED for a system variable and you will cause lots of problems!

2. Why do you need to copy ADDITIONAL files into a program directory? This is bad security practice.
1. Path in this command this is string value - REG_SZ > Path > C:\Program Files\7-Zip
2. Program directory is only example. Quote
for /f "tokens=3" %a in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\7-Zip" /v Path ^| find /i "REG_SZ"') do set Path=%a

Your code uses Path as a variable name. Use something else e.g. Mypath

Now %Mypath% contains a path

copy some files into that folder

copy *.txt "%Mypath%"

I cant use Mypath in this example, becouse name of string value is "Path" . In other cases it can be InstallPath or InstallLocation etc.
Is not a problem I check this in cmd with command: SET , and everything is fine with system "Path"

7-Zip is only example, because there was a high probability that someone who try to help will have this program

Quote
The task is: find in registry path to the program, copy files (with other extensions) from folder where i have batch file and paste copied files to folder from path .

Possible ?

Possible ?Quote
Your code uses Path as a variable name. Use something else e.g. Mypath

Now %Mypath% contains a path

copy some files into that folder

copy *.txt "%Mypath%"

Thats it ! Working like a charm. THANK You very much Quote from: Bzik on July 16, 2013, 01:14:19 PM
I cant use Mypath in this example, becouse name of string value is "Path"

You can use anything you like. You are not understanding that Path is the name (in the registry) of the registry key. In your batch you can use any variable name you like to hold the string value of the registry key.

Code: [Select]@echo off
for /f "tokens=1-2*" %%A in ('reg query HKEY_CURRENT_USER\Software\7-Zip /v path ^| find "REG_SZ"') do set MyPath=%%C
echo The path string value is "%MyPath%"


If you did set Path=%%C you would find that all external commands would stop working in that command session.
Yes, You right. Mypath is working.

Thanks again.


Discussion

No Comment Found