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]));
}