Reputation: 1166
I want to FTP some files across networks using Windows FTP command prompt and I want to retrieve the FTP parameters from registry keys I have already setup for another related application.
Is there a way to read these parameters in-line direct from the registry as passed values into the FTP command?
Upvotes: 1
Views: 8849
Reputation: 211
You can read a registry entry into an environment variable using reg query... (the following example is for use in .bat files)
@SET MSBUILDDIR=
@for /F "tokens=1,2*" %%i in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions\3.5" /v "MSBuildToolsPath"') DO (
if "%%i"=="MSBuildToolsPath" (
SET "MSBUILDDIR=%%k"
)
)
@if "%MSBUILDDIR%"=="" exit /B 1
Upvotes: 12
Reputation: 27509
You can use command line switches on regedit.exe to read/write values. Whether you can do it directly in line for another command I don't know (but I doubt it).
Maybe you can use '>' to store the output in a text file, then read it in for your input to the next command. It would have to be multiple commands in a batch file to do that.
Or, if you can use reg.exe. (don't think it's installed by default - Can't remember, think it comes with the windows server resource kit or something like that)
(Or just use powershell)
Upvotes: 3