 2008/12/05
|
Last update 1999/02/20
TPJ: Issue_08_Win32
- settime
- adduser
- group
- sysinfo
- spawn
- getdrives
- More Samples on Win32
Download settime
|
use Win32::AdminMisc;
|
|
use Win32::NetAdmin;
|
|
|
|
srand(time);
|
|
$Domain = "SOUTH_PARK";
|
|
$Server = "\\\\ServerName";
|
|
Win32::NetAdmin::GetServers($Server, $Domain, SV_TYPE_ALL, \@List);
|
|
foreach $Machine (@List) {
|
|
$Time = sprintf("3:%02d am", int(rand(60)));
|
|
if (Win32::AdminMisc::ScheduleAdd($Machine,
|
|
$Time,
|
|
0,
|
|
SUNDAY,
|
|
JOB_RUN_PERIODICALLY | JOB_NONIN\
|
|
TERACTIVE,
|
|
"net time \\\\server /s /y") {
|
|
print "Job added to $Machine for $Time every Sunday.\n";
|
|
} else {
|
|
print "Job not added to $Machine.\n";
|
|
}
|
|
}
|
Download adduser
|
Win32::NetAdmin::UserCreate(
|
|
$Domain, # Domain
|
|
$User, # Userid
|
|
$Password, # Password
|
|
$PasswordAge, # Password Age
|
|
USER_PRIV_USER, # Privileges
|
|
$HomeDir, # Home director\
|
|
y
|
|
$Comment, # Comment
|
|
UF_NORMAL_ACCOUNT | UF_SCRIPT, # Flags
|
|
"c:\\scripts\\$User.bat" # Logon sc\
|
|
ript
|
|
);
|
Download group
|
sub IsMember{
|
|
my($Server, $Group, $User) = @_;
|
|
return (Win32::GroupIsMember($Server, $Group, $User) ||
|
|
Win32::NetAdmin::LocalGroupIsMember($Server, $Group,
|
|
$User));
|
|
}
|
Download sysinfo
|
if (%Data = Win32::AdminMisc::GetProcessorInfo()){
|
|
print "Memory Information:\n";
|
|
print "\tNumber of processors: $Data{ProcessorNum}\n";
|
|
print "\tType of processor: $Data{ProcessorType}\n";
|
|
print "\tProcessor level: $Data{ProcessorLevel}\n";
|
|
print "\tProcessor revision: $Data{ProcessorRevision}\n";
|
|
print "\tPage size: $Data{PageSize}\n";
|
|
}
|
|
if (%Data = Win32::AdminMisc::GetMemoryInfo()){
|
|
print "\nMemory Information:\n";
|
|
print "\tMemory available: $Data{RAMAvail}\n";
|
|
print "\tMemory total: $Data{RAMTotal}\n";
|
|
print "\tVirtual mem avail: $Data{VirtAvail}\n";
|
|
print "\tVirtual mem total: $Data{VirtTotal}\n";
|
|
print "\tPage mem available: $Data{PageAvail}\n";
|
|
print "\tPage mem total: $Data{PageTotal}\n";
|
|
print "\tCurrent memory load: $Data{Load}\n";
|
|
}
|
|
if (%Data = Win32::AdminMisc::GetWinVersion()){
|
|
print "\nWindows Information:\n";
|
|
print "\tPlatform: $Data{Platform}\n";
|
|
print "\tVersion: $Data{Major}.$Data{Minor}\n";
|
|
print "\tBuild: $Data{Build}\n";
|
|
print "\tService Pack version: $Data{CSD}\n";
|
|
}
|
Download spawn
|
use Win32::AdminMisc;
|
|
if (Win32::AdminMisc::LogonAsUser($Server, "Cartman", "CheesyPuff"=
|
|
)){
|
|
$User = Win32::AdminMisc::GetLogonName();
|
|
$Result = Win32::AdminMisc::CreateProcessAsUser(
|
|
"cmd.exe",
|
|
"Flags", CREATE_\
|
|
NEW_CONSOLE,
|
|
"XSize", 640,
|
|
"YSize", 400,
|
|
"X", 200,
|
|
"Y", 175,
|
|
"XBuffer", 80,
|
|
"YBuffer", 175,
|
|
"Show", SW_MINIM\
|
|
IZE,
|
|
"Title", "$User'\
|
|
s process",
|
|
"inherit", 1,
|
|
"Fill", BACKGROU\
|
|
ND_BLUE |
|
|
FOREGROUND_RED |
|
|
FOREGROUND_BLUE \
|
|
|
|
|
FOREGROUND_INTEN\
|
|
SITY |
|
|
FOREGROUND_GREEN\
|
|
,
|
|
);
|
|
}
|
| Issue_08_Win326. getdrives
|
Download getdrives
|
@Drives = Win32::AdminMisc::GetDrives();
|
|
foreach $Drive (sort(@Drives)){
|
|
$Type = Win32::AdminMisc::GetDriveType($Drive);
|
|
($Total, $Free) = Win32::AdminMisc::GetDriveSpace($Drive);
|
|
if ($Type == DRIVE_FIXED){
|
|
$Type = "hard drive";
|
|
}elsif ($Type == DRIVE_REMOVALBE){
|
|
$Type = "removable (floppy) drive";
|
|
}elsif ($Type == DRIVE_REMOTE){
|
|
$Type = "network drive";
|
|
}elsif ($Type == DRIVE_CDROM){
|
|
$Type = "CDROM drive";
|
|
}elsif ($Type == DRIVE_RAMDISK){
|
|
$Type = "RAM disk";
|
|
}else{
|
|
$Type = "disk type $Type";
|
|
}
|
|
print "The $Drive is a $Type and has a size of $Total bytes with $\
|
|
Free bytes available.\n";
|
|
}
|
| Issue_08_Win327. More Samples on Win32
|

Last update 1999/02/20 
All Rights Reserved - (C) 1997 - 2008 by The Labs.Com |