This program does 4 things to remote computers, you can either create a text file will a list of computer names or enter the computer name yourself. I also have a error file that it is suppose to print to when something fails. It does this when you enter the computer name yourself but when you use the txt file it only does the first one.

use Tk; use Tk::Dialog; use Win32; use Win32::NetAdmin; use Win32::AdminMisc; my @details; my $NewGuestUser = "DisabledGuestAccount"; my $Guestuser = "Guest"; my $Adminuser = "Administrator"; my $NewAdminUser = "testadmin"; my $Guest; my $Admin; my $AdminPass; my $server; my @computers; my $mw = MainWindow->new; my $c = $mw->Canvas(-width => 570, -height => 450); $c->pack; sub trans { open (OUTPUT, ">Error.txt"); if ($server =~ m/txt/) { open(DAT, $server) || die("Could not open file!"); @computers=<DAT>; close(DAT); foreach $computer (@computers) { chop($computer); } } else { @computers = $server; print OUTPUT "$server\n"; } foreach $computer (@computers) { print OUTPUT "$computer\n"; $text->insert ("end", "$computer\n"); if ($CheckRenameAdmin) { AdminRename(); $text->insert ("end", "$comments"); } if ($CheckAdminPassword) { AdminPasswordSet(); $text->insert ("end", "$comments"); } if ($CheckRenameGuest) { GuestRename(); $text->insert ("end", "$comments"); } if ($CheckDisableGuest) { GuestDisable(); $text->insert ("end", "$comments"); } $comments = "==========================================\n"; print OUTPUT "==========================================\n"; $text->insert ("end", "$comments"); close(OUTPUT); } } ###################################################################### +###################################### sub quit { $d = $mw->Dialog( -text => "Are you sure you want to quit?", -buttons => ["Yes", "No"] ); $answer = $d->Show(); exit if ($answer eq "Yes") } ###################################################################### +###################################### sub GuestRename { $Guest = Win32::AdminMisc::RenameUser($server, $Guestuser, $NewGue +stUser); #print OUTPUT Win32::AdminMisc::GetError(); if ($Guest == 1) { $comments = "The user $Guestuser was changed to $NewGuestUser\ +n"; } else { $comments = "The user $Guestuser was not changed to $NewGuestU +ser\n"; print OUTPUT "The user $Guestuser was not changed to $NewGues +tUser\n"; } } ###################################################################### +###################################### sub GuestDisable { $DisableGuest1 = Win32::AdminMisc::UserSetMiscAttributes($server, $New +GuestUser, USER_FLAGS => UF_ACCOUNTDISABLE | UF_PASSWD_CANT_CHANGE | UF_DONT_ +EXPIRE_PASSWD); #print OUTPUT Win32::AdminMisc::GetError(); if ($DisableGuest1 == 1) { $comments = "The Guest has been disabled\n"; } else { $comments = "The Guest account was not disabled\n"; print OUTPUT "The Guest Acount was not disabled\n"; } } ###################################################################### +###################################### sub AdminRename { $Admin = Win32::AdminMisc::RenameUser($server, $Adminuser, $NewAdm +inUser); #print OUTPUT Win32::AdminMisc::GetError(); if ($Admin == 1) { $comments = "$Adminuser has been renamed to $NewAdminUser\n"; } else { $comments = "$Adminuser was not renamed to $NewAdminUser\n"; print OUTPUT "$Adminuser was not renamed to $NewAdminUser\n"; } } ###################################################################### +#################################### sub AdminPasswordSet { $AdminPassP = Win32::AdminMisc::SetPassword($server, $NewAdminUser +, $AdminPass); #print OUTPUT Win32::AdminMisc::GetError(); if ($AdminPassP == 1) { $comments = "Admin password has been set\n"; } else { $comments = "Admin password set has failed\n"; print OUTPUT "Admin password set has failed\n"; } } ###################################################################### +##################################### $mw->title ("Admin Tools"); $text = $mw->Scrolled('Text', -scrollbars => 'so'); $text->insert ("end", "Details\n"); $lab = $mw->Label( -text => 'Select your choices'); $quit = $mw->Button( -text => "Quit", -command => \&quit); $run = $mw->Button( -text => "Run", -command => \&trans); $adminrename = $mw->Checkbutton( -text => "Rename Admin Account", -variable => \$CheckRenameAdmin ); $adminSetPass = $mw->Checkbutton( -text => "Set Admin Password", -variable => \$CheckAdminPassword ); $Guestrename = $mw->Checkbutton( -text => "Rename Guest Account", -variable => \$CheckRenameGuest ); $GuestDisable = $mw->Checkbutton( -text => "Disable Guest Account", -variable => \$CheckDisableGuest ); $Servername = $mw->Entry( -textvariable => \$server ); $Adminpass = $mw->Entry( -textvariable => \$AdminPass ); $TextAdminPass = $mw->Label( -text => "New Admin Password:"); $TextServerName = $mw->Label( -text => "Enter server or .txt file"); $adminrename->place(-x =>0, -y => 15); $Guestrename->place(-x =>0, -y => 32); $adminSetPass->place(-x =>0, -y => 49); $GuestDisable->place(-x =>0, -y => 64); $text->place(-x => 4, -y => 89); $quit->place(-x => 540, -y => 47); $run->place(-x => 500, -y => 47); $lab->place(-x => 0, -y => 0); $Servername->place(-x => 180, -y => 55); $Adminpass->place(-x => 320, -y => 55); $TextAdminPass->place(-x => 327, -y => 32); $TextServerName->place(-x => 187, -y => 32); MainLoop;

2006-03-21 Retitled by planetscape, as per Monastery guidelines
Original title: 'Help'


In reply to Help with error output by SteveS832001

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.