I'm getting this error after my program prompts for the hostname and reg key and value.: "Can't locate object methond "connect" via package Win32::TieRegistry" (perhaps you forgot to load "Win32::TieRegistry" at line 26, <STDIN> line 3.
Here;s what i have
# This program will add a System Environment Variable. It will require
+ a reboot to take
# effect.
#!/usr/bin/perl -w
use strict;
my ($Reg, $Host, $Key, $Value);
use Win32::TieRegistry (
TiedRef => \$Reg,
ArrayValues => 1,
Delimiter => '/',
':REG_'
);
# Asking for machine name and info to be added to the sys env var
print "What host would you like to connect to? ";
chomp($Host = <STDIN>);
print "What name would you like for the Sys Environment Variable? ";
chomp($Key = <STDIN>);
print "What value would you like to assign to this variable? ";
chomp($Value = <STDIN>);
# this is the system environment variable area
my $SysEnv= $Reg->connect("$Host", "LMachine/System/CurrentControlSet/
+Control/" .
"Session Manager/Environment/")
or die "Can't connect to $Host 's registry or can't open Registry
+ key, Session Manager/Environment: $^E
+\n";
# create a new value and set it's data
$SysEnv->{"/$Key"} = "$Value";
Any help would be appreciated by my fellow monks. :o)
~Ray~
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.