Monday, April 20, 2009

For loop of death

This is a way to somewhat defend yourself when a process keeps on respawning itself and won't go away. This happens quite a bit when XP gets infiltrated by malware.




for /l %a in (1,1,1000000) do taskkill /im malware.exe /f

Universal scripted uninstall (XP)

Given the displayname value, this vbscript will go and find it in the registry and uninstall the corresponding program.

This is where it searches:

hklm\software\microsoft\windows\currentversion\uninstall



' arg 1 - displayname


if (wscript.arguments.count > 0 ) then

set shell = wscript.createobject("wscript.shell")
strcmd = "reg query hklm\software\microsoft\windows\currentversion\uninstall /s"

set oexec = shell.exec(strcmd)

temp = 0
parent = ""

do while not oexec.stdout.atendofstream

strline = oexec.stdout.readline


if len(strline) > 0 then
a=split(strline,vbtab)
if mid(trim(a(0)),1,4) = "HKEY" then
b = split(trim(a(0)),"\")
parent = b(ubound(b))
temp = 1
end if
alen = ubound(a) + 1
if alen >= 3 then
if trim(a(0)) = "DisplayName" and trim(a(2)) = wscript.arguments(0) and temp = 1 then
wscript.echo "msiexec /x " & parent & " /qn"
temp = 0
shell.exec("msiexec /x " & parent & " /qn")
exit do
end if

end if
end if
loop




end if

Sunday, April 19, 2009

Solution to generating markers along a route at a regular interval

I found this neat javascript extension for the google map api. Here is the link:

http://econym.org.uk/gmap/epoly.htm

You specify the distance and give it a polyline and it returns an array of points along the route.



map.setCenter(new GLatLng(42.351505,-71.094455), 15);
var directionsPanel = document.getElementById("directions_div");
var directions = new GDirections(map, directionsPanel);
var address = "from: trenton, nj to: philadelphia, pa";

directions.load(new_address);
if (directions == null){
alert("Error: directions object is null");
return;
}

var pl = directions.getPolyline();

if (pl == null){
alert("Error: polyline object is null");
return;
}

var points = pl.GetPointsAtDistance(1609.344);

if (points == null){
return;
}

for (var i=0; i
map.addOverlay(new GMarker(points[i]));
}



Friday, December 19, 2008

Viruses are back again!

Just when you thought XP Antivirus 2008 died out, enter AntiSpyware 2009. This piece of crap gets on your machine by screwing up internet explorer and the startup environment. The damn thing protects itself even in safe mode. I'm not sure how it does this; usually this is done with winlogon.exe, but the winlogon registry key seemed to be clean. We've just been reghosting the machine. Watch where you click! When you see a dialog box about spyware (and it's definitely not your antivirus software) restart your machine (this dialog box is from internet explorer).

Blackberry desktop manager

Working with the BDM has not been a general pleasure for me and other technicians where I work. It doesn't sync all the time, most likely due to corrupt organizer data and/or buggy software. The weird thing is that it was working kind alright when we had an Exchange server, but it got crappy when we migrated to a MAPI connector with Sun. I got it syncing by installing the exchange redirector BDM (we're still using outlook) and disabling redirection?! In the process of stumbling on this, I became familiar with just about every troubleshooting BB trick. Fun!

Wednesday, August 27, 2008

IT Rant II : Disk Imaging

If you have many computers, then you probably dread the time of year where you have to refresh their configurations. There are so many solutions available, but the ones that work and are simple to use are few and far between. Ghost 11 is not one of those programs, and neither is NetInstall for OS X 10.4.11. Ghost 11 would not clone Windows x64 nor regular XP sp3 (it worked for me before with Vista). I have gotten NetInstall to work in the past, but there was some issue with System Image utility failing to copy files. It looks like Apple has done a half ass job of updating OS X once again. I should have upgraded to Leopard server... I guess it's back to my reliable friend disk utility for restores until that happens.

Recently, my disk masters have reached very great sizes -- 100GB and up. This becomes a matter of give and take, because I want to do all my setups on the master. However, by doing so, I am creating images that are far too large. If I have sample files and/or programs that can be copied later, then this is the thing to do. I can copy the files with for loops like so:

Mac -
for ((i=1;i<21;i++))
do
scp somefile mylogon@station${i}.local:samples #make sure you copy the public key from ssh-keygen
done # to each station in ~/.ssh


Windows-
for /l %a in (1,1,20) do copy samplefile.txt \\station%a\c$\samples

There are all kinds of ways to simplify network tasks, but this still doesn't give us an excuse to procrastinate when building disk images. Try and do everything that is to be cloned in the master. Also, try to save space.

Friday, August 1, 2008

Yes, you can script anything I - vbscript: sendkeys, stdout

What happens when you want to automate some configuration and you can't find the command line equivalent, the registry setting eludes you, and the apis to do the task seem too elaborate? Well just do it with it a few key strokes, but have vbscript do the operations for you. It's like doing a macro in excel or your favorite application.

Check out this link for the sendkeys method in wsh.

A lot times I am frustrated by trying to get Windows to act like Unix. When I want to do some string processing, it seems easier just to use vbscript and call the commandline from there. You can collect the information from stdout with the WScript.Shell object.

Check out this example.