You can only set environment variables to a string value, a numerical expression (using "set /a") or a user provided input string (using "set /p"). What you are doing here is setting the variable VERSION to the command text string. In other words, the reg query command is never evaluated. Try the following: for /f "skip=4 tokens=3" %V in ('reg query HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{98EC8E7A-161A-455B-8B31-1E88C1CDFA6B} /v DisplayVersion') do set VERSION=%V This will evaluate the reg query command, skip the first four lines of output and then assign the third token on the next line to the variable %V (case sensitive!), which is then assigned to the VERSION environment variable. Remember to use %%V instead of %V in a batch file. Type "for /?" in a command window for details.