I try to get the installation location of the program without checking a number of hard-coded paths, hoping to get them from the path stored in the Windows registry, but I get empty return values ββor error messages when I try to read the required key values.
I read about Parsing windows registry using Perl , and I think I included all the answers in my script, but I always get an empty result when I try to read the registry value, even if you run from an elevated command prompt to make sure that the script has administrator rights.
At first I tried to use Win32 :: TieRegistry, and as mentioned, the return value is empty, so I tried just to bypass and use reg query , but this gives an error in that the key was not found. Running the same reg query command outside of Perl successfully reads the key. What am I doing wrong?
Update. The main reason (indicated in the pair's responses received) was trying to access the 64-bit registry representation from 32-bit Perl ; by default, any 32-bit Windows application is redirected to HKLM\Software\WOW6432Node when trying to access the HKLM\Software keys, so I need to find a way to avoid this, since my interesting key does not exist in this place.
Perl script:
#!/usr/bin/perl -w use strict; use Data::Dumper; use Win32::TieRegistry (Delimiter => '/'); my $mykey = $Registry->{'HKEY_LOCAL_MACHINE/Software/ikv++ technologies ag/medini unite (x64)'}; my $mykeyval = $mykey->{'/Path'}; print " value=$mykeyval\n"; print Dumper $mykey; my $sysCmd =`reg query "HKLM\\Software\\ikv++ technologies ag\\medini unite (x64)" /v Path`; print " sysCmd=$sysCmd\n";
Output:
C:\Users\username\AppData\Local\Temp>perl test_reg_read.pl Use of uninitialized value in concatenation (.) or string at test_reg_read.pl line 9. value= $VAR1 = {}; ERROR: The system was unable to find the specified registry key or value. sysCmd=
reg query command outside Perl:
C:\Users\username\AppData\Local\Temp>reg query "HKLM\Software\ikv++ technologies ag\medini unite (x64)" /v Path HKEY_LOCAL_MACHINE\Software\ikv++ technologies ag\medini unite (x64) Path REG_SZ C:\Program Files\ikv++ technologies ag\mediniUnite
Note that all this is done from an elevated command prompt; as soon as he works there, I was going to experiment with necessity.