use Win32::OLE qw( in );
use Win32::OLE::Variant;
use Win32::IPConfig;
use Socket ;
#Purpose to start remote process :Usage: perl filename.pl exe_to_run.exe
#usage : $0 hostDomainName executableName.exe Argument1 Argument2
our $Machine = $ARGV[0];
our @ARGV = @ARGV[1..$#ARGV] ; #cut the host's name from the comma1nd line
our $CLASS = "WinMgmts:{impersonationLevel=impersonate}!//$Machine";
main();
sub main
{
getIpFromDomainName($Machine);
my $success = startProc();
my $counter = 0 ;
while ( $success == 0 && $counter <= 3 )
{
$success = startProc();
$counter ++ ;
}
if ($success == 0)
{
open ( FH , ">C:/Temp/TEMP/$Machine.txt" ) or
die "cannot open $Machine.txt $! \n" ;
print FH "$Machine failed to execute command :\n" ;
foreach (@ARGV)
{ chomp($_);
print FH "$_ " ;
}
close FH ;
}
}
sub getIpFromDomainName
{
my $host = shift ;
my $hostIp = () ; #the ip of the host we are going to return
my $address = gethostbyname("$host") ;
# print gethostbyname($_) , "\n" ;
print inet_ntoa($address) , "\n" ;
$hostIp = inet_ntoa($address) ;
return $hostIp ;
#eof sub getIpFromDomainName
}
sub startProc
{ #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 "PID $vPid\n";
sleep 2 ;
return 1 ;
}
else
{
print "Failed .\n";
sleep 2 ;
return 0 ;
}
} #eof startProc
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 !!!!