in reply to Open an application from windows registry

Have you tried running the code as administrator ?

Update : Change this line to use double quotes - see Quote-Like-Operators

my $mykey = $Registry->{"HKEY_LOCAL_MACHINE/Software/SPS/$version"}

poj

Replies are listed 'Best First'.
Re^2: Open an application from windows registry
by ElAlx (Initiate) on Feb 27, 2017 at 08:33 UTC
    Hello, if i sepcifiy the path in registry without using the content of $version it works. I tryied with "" and running it as admin, it makes unfortunately no difference.

      Single quotes don't interpolate variables. Double quotes do.

      use Win32::TieRegistry (Delimiter => '/'); my $version=2.1; my $key_single = 'HKEY_LOCAL_MACHINE/Software/SPS/$version'; my $key_double = "HKEY_LOCAL_MACHINE/Software/SPS/$version"; print "Single quotes: <$key_single>\n"; print "Double quotes: <$key_double>\n";

      See perlop

        Thanks, i ran it again as admin and it worked.

      edit: nevermind, it had typos and got me confused, i guess i should be asleep

      use Win32::TieRegistry (Delimiter => '/'); my $version=2000; { my $mykey0 = $Registry->{"HKEY_LOCAL_MACHINE/SOFTWARE/ActiveState/Acti +vePerl/$version"}; print 'MK0:'.$mykey0."\n"; } { my $mykey2 = $Registry->{"HKEY_LOCAL_MACHINE/Software/ActiveState/Acti +vePerl/$version"}; print 'MK2:'.$mykey2."\n"; } { my $mykey = $Registry->{"HKEY_LOCAL_MACHINE/SOFTWARE/ActiveState/Activ +ePerl/$version/"}; print 'MK1:'.$mykey."\n"; my $mykeyval = $mykey->{'Help//'}; print 'MV1:'.$mykeyval."\n"; } { my $part='TroubleShooters'; my $mykey = $Registry->{"HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/DeviceM +anager/$part/"}; print 'ms1:'.$mykey."\n"; my $mykeyval = $mykey->{'/TroubleShooter-3'}; print 'ms2:'.$mykeyval."\n"; } __END__ my $version='2.1'; my $mykey = $Registry->{"HKEY_LOCAL_MACHINE/SOFTWARE/SPS/$version/"}; my $mykeyval = $mykey->{'/AppsDir'}; $mykeyval2="$mykeyval"."\\start.exe"; system("$mykeyval2");
      This works just fine, no caps, no slash needed at end, does need double quotes.


      this is original with typos

      use Win32::TieRegistry (Delimiter => '/'); my $version=2000; { my $mykey0 = $Registry->{"HKEY_LOCAL_MACHINE/SOFTWARE/ActiveState/Acti +vePerl/$version"}; print 'MK0:'.$mykey."\n"; } { my $mykey2 = $Registry->{"HKEY_LOCAL_MACHINE/Software/ActiveState/Acti +vePerl/$version"}; print 'MK2:'.$mykey."\n"; } { my $mykey = $Registry->{"HKEY_LOCAL_MACHINE/SOFTWARE/ActiveState/Activ +ePerl/$version/"}; print 'MK1:'.$mykey."\n"; my $mykeyval = $mykey->{'Help//'}; print 'MV1:'.$mykeyval."\n"; } { my $part='TroubleShooters'; my $mykey = $Registry->{"HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/DeviceM +anager/$part/"}; print 'ms1:'.$mykey."\n"; my $mykeyval = $mykey->{'/TroubleShooter-3'}; print 'ms2:'.$mykeyval."\n"; } __END__ my $version='2.1'; my $mykey = $Registry->{"HKEY_LOCAL_MACHINE/SOFTWARE/SPS/$version/"}; my $mykeyval = $mykey->{'/AppsDir'}; $mykeyval2="$mykeyval"."\\start.exe"; system("$mykeyval2");
      Result
      MK0: MK2: MK1:Win32::TieRegistry=HASH(0xb6e354) MV1:C:\Perl\html\index.html ms1:Win32::TieRegistry=HASH(0xa3ec64) ms2:hcp://help/tshoot/Err_Hardw_Error3.htm
      First you need the double quotes,
      Second SOFTWARE is all caps,
      Third "subkey-name" has to end in a slash (delimiter).

      http://search.cpan.org/~adamk/Win32-TieRegistry-0.26/lib/Win32/TieRegistry.pm
      "Hash key string ends with a delimiter
      If the key string ends with a delimiter, then it is treated as a subkey name or path of subkey names separated by delimiters."

      what i think should work for you is below the __END__, i cant test it 'cuz i dont have SPS