use Win32::OLE qw( in );
use Win32::OLE::Variant;
use Win32::IPConfig;
#usage : StartRemoteProcess TheDomainNameOfTheHost the executable and any other command line parameters
#RUNAS /profile /user:userName "StartRemoteProcess TheDomainNameOfTheHost executable command line parameters" | sanur password
our $Machine = $ARGV[0];
our @ARGV = @ARGV[1..$#ARGV] ; #cut the host's name from the command line
our $CLASS = "WinMgmts:{impersonationLevel=impersonate}!//$Machine";
main();
sub getIpFromDomainName
{
my $host = shift ;
my $hostIp = () ; #the ip of the host we are going to return
my $ipconfig = Win32::IPConfig->new($host)
or die "Unable to connect to $host\n";
print "Host Name. . . . . . . . . . . . : ", $ipconfig->get_hostname, "\n";
print "Domain Name (Primary). . . . . . : ", $ipconfig->get_domain, "\n";
my @searchlist = $ipconfig->get_searchlist;
print "Search List. . . . . . . . . . . : $searchlist[0]\n";
print " $searchlist[$_]\n"
for (1..@searchlist-1);
print "Node Type . . . . . . . . . . . : ", $ipconfig->get_nodetype, "\n";
print "IP Routing Enabled . . . . . . . : ",
$ipconfig->is_router ? "Yes" : "No", "\n";
print "WINS Proxy Enabled . . . . . . . : ",
$ipconfig->is_wins_proxy ? "Yes" : "No", "\n";
print "LMHOSTS Enabled. . . . . . . . . : ",
$ipconfig->is_lmhosts_enabled ? "Yes" : "No", "\n";
print "DNS Enabled for NetBT. . . . . . : ",
$ipconfig->is_dns_enabled_for_netbt ? "Yes" : "No", "\n";
for my $adapter ($ipconfig->get_configured_adapters) {
print "\nAdapter '", $adapter->get_name, "':\n\n";
print "DHCP Enabled . . . . . . . . . . : ",
$adapter->is_dhcp_enabled ? "Yes" : "No", "\n";
print "Domain Name. . . . . . . . . . . : ", $adapter->get_domain, "\n";
my @ipaddresses = $adapter->get_ipaddresses;
my @subnet_masks = $adapter->get_subnet_masks;
for (0..@ipaddresses-1) {
print "IP Address . . . . . . . . . . . : $ipaddresses[$_]\n";
return $hostIp ;
}
} #eof sub getIpFromDomainName
my @gateways = $adapter->get_gateways;
print "Default Gateway. . . . . . . . . : $gateways[0]\n";
print " $gateways[$_]\n"
for (1..@gateways-1);
my @dns = $adapter->get_dns;
print "DNS Servers. . . . . . . . . . . : $dns[0]\n";
print " $dns[$_]\n" for (1..@dns-1);
my @wins = $adapter->get_wins;
print "WINS Servers . . . . . . . . . . : $wins[0]\n";
print " $wins[$_]\n" for (1..@wins-1);
################################################
####################################################
sub main
{ #todo
my $hostIp = getIpFromDomainName($Machine);
$WMI = Win32::OLE-> GetObject( $CLASS ) || die "Unable to connect to
$Machine:" . Win32::OLE->lastError();
$PROCESSSTARTUP = $WMI-> Get("Win32_ProcessStartup")->SpawnInstance_;
$PROCESSSTARTUP-> {WinstationDesktop} = "winsta0\\default";
$PROCESSSTARTUP-> {ShowWindow} = 1;
print "$PROCESSSTARTUP-> {WinstationDesktop}\n";
$Process = $WMI-> Get( "Win32_Process" ) || die "Unable to get the
process list:" . Win32::OLE-> LastError();
$vPid = Variant( VT_I4 | VT_BYREF, 0 );
if( 0 == $Process-> Create( join( " ", @ARGV ), undef,
$PROCESSSTARTUP, $vPid ) ) {
print "Process successfully created with PID $vPid\n";
}
else
{
print "Failed to create process.\n";
}
}
} #eof main
Getting the Current TabItem when the Tab is not selected in WPF
-
[image: Banner]
This is a quick reminder to self on how to retrieve a TabItem from a WPF
TabControl *when the tab is not currently selected* because I ru...
1 month ago
No comments:
Post a Comment
- the first minus - Comments have to be moderated because of the spammers
- the second minus - I am very lazy at moderating comments ... hardly find time ...
- the third minus - Short links are no good for security ...
- The REAL PLUS : Any critic and positive feedback is better than none, so your comments will be published sooner or later !!!!