Showing posts with label win32. Show all posts
Showing posts with label win32. Show all posts

Friday, November 7, 2008

Killing RDP Session

It seems that some idiots prefer to click the x, of RDP client, rather than logging off the session properly. Clicking the x would leave the session exists in disconnected status, but not destroyed.

This is the remedy (besides bashing their heads repeatedly).

Query for the session IDs:
> qwinsta /SERVER:[server name]

SESSIONNAME USERNAME ID STATE TYPE DEVICE
console username 0 Active wdcon
rdp-tcp 65536 Listen rdpwd
jackass1 1 Disc rdpwd
jackass2 2 Disc rdpwd
Now, kill those stranglers:
> logoff 1 /SERVER:[server name]
> logoff 2 /SERVER:[server name]
Remember: you need to be an administrator of [server name] to do this.

More command line goodies: http://dev.remotenetworktechnology.com/cmd/tscmd.htm

Saturday, January 19, 2008

XP SP2 Does Not Have WPA2 Driver

Have to hunt the fix (KB893357) using Google.

Monday, November 12, 2007

Automated Deployment, Part I: Uninstall The Olde Crap

To harvest the command line to uninstall an application, launch the regedit application and browse the registry tree to HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall, each key afterwards is a application key, a string of characters that means nothing if it is coded by baboon(s). The crucial items are these value name of the application key and it's content:
  1. DisplayName: the name of the application
  2. UninstallString: the command line to uninstall the application.
To get all of the useful information using perl:

use strict;
use Win32::TieRegistry;
my $machine = 'localhost'; # make sure the RemoteRegistry services is up
# and the script is executed with user within
# administrator group.
my $register = 'HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows'.
'/CurrentVersion/Uninstall';
$register = "//$machine/$register";

$Registry->Delimiter("/");
my $remoteKey = $Registry->{$Register};
if (defined $remoteKey) {
foreach my $appKey ( $remoteKey->SubKeyNames ) {
my $DisplayName = $Registry->{"$Register/$appKey/DisplayName"};
my $UninstallString = $Registry->{"$Register/$appKey/UninstallString"};
if (defined $UninstallString && defined $DisplayName) {
$app{$DisplayName} = $UninstallString;
}
}
}
open LOG, ">$0.txt";
foreach my $appName (sort keys %app) {
print LOG "$appName, $app{$appName}\n";
}
close LOG;

Usually, there are two kinds of command line, the first one is an executable binary and customized MSI script (the command line starts with msiexec.exe). If you happen to encounter the later one, you are in luck, if not, pray that the baboon put in the quiet mode in the binary.

If the uninstallation string uses msiexec.exe, just put in /quiet at the back of the string to launch quiet installation.