July 7, 2010

Chaocipher: Interactive Web Form

Filed under: Uncategorized — Kevmar @ 7:06 pm

After my quick implementation of Chaocipher in PowerShell, I decided to redo it in JavaScript as an interactive form.  My JavaScript was a bit more rusty than I expected.  The code is not near as clean as I would have liked it to be.

Message:
Left Alpha:
Right Alpha:
Encrypt:
Results:

June 26, 2010

Signing scripts the easy way: VBS, JS, WScript, CScript

Filed under: Script,Uncategorized — Tags: — Kevmar @ 4:06 pm

If you have a code signing cert, it is very easy to sign scripts.  Here is the VBS script I use to sign them with.

Set objSigner = WScript.CreateObject("Scripting.Signer")
objSigner.SignFile WScript.Arguments(0), "Kevin Marquette"

I save that in a file called SignScript.vbs on my computer where my cert is installed into the local store. My cert is named “Kevin Marquette” and the script I want signed is passed as arg0 from the command line like this:

c:\> SignScript myScript.vbs

I take this one step further by adding a sign option on the right click context menu from explorer. This is very easy to set up if you get it working from the command line. From regedit, open HKEY_CLASS_ROOT, and find VBSFile (or JSFile). Under the key called Shell, add a key called “Sign”. This is what will show up in the context menu. Under the key you added, add a new key called “command”. Then set the default value on that “command” key to match this .reg file.

[HKEY_CLASSES_ROOT\VBSFile\Shell\Sign\command]
@="\"c:\\windows\\System32\\CScript.exe\" C:\\Scripts\\SignScript.vbs \"%1\""

Now when you right click a .vbs file, you can sign it.

June 1, 2010

MSI Deployment Rate.

Filed under: Uncategorized — Kevmar @ 9:34 am

How fast do MSI installs get deployed out to the network?  Lets take a look at the process.  You build a new MSI and assign it to every computer in your network with AD.  The next time the computer refreshes its policies it will now about the MSI to be installed.  The MSI will be installed when the computer gets rebooted.  If the computer refreshes the policy on a reboot then it will go ahead and install the MSI.  So the simple answer is on the next reboot.

But when is the next reboot?  In a large network you have lots of different users that have different habits.  Some power off at night and others just lock the computer.  I decided that knowing how fast my network gets MSI installed loaded would be a good piece of information to have.  So I set out to test it.

I was just about to deploy an asset tracking solution using MSI to all of our computers.  Once the client was installed on the computer it would check in to report its information.  This is what gave me the idea.  I could tell exactly when every computer reported in.  So I pushed out the MSI and started tracking the numbers.

We are currently having issues with our Windows 7 computers pulling policies correctly so I tracked Win7 and WinXP numbers.  It is a strange issue that I will save for another time.  I collected the data on business days from 5/20/2010 to 6/1/2010 for a total of 8 samples.  I had a total of 320 computers report in and that was in the range of 300-330 that I expected.  I did about 15 installs by hand verifying and testing the MSI.

The next day after I started deployment, I had 35% of the computers load the software.  I would get fewer and fewer reports each day after that.

This chart shows how many computers loaded the MSI over time.  Point 2 is the first day after I deployed the MSI.  The large jump at point 8 was the result of me sending out a computer reboot command.

This is the rate of deployment.  How many were deployed each day.  Again you can see the network wide reboot on data point 8.  The installs were getting slower and slower.  Performing the reboot after 7 days picked up 26% of the computers.

The first night picked up 35% of the computers. The next 2 days picked up another 24%. Days 4,5, and 6 picked up 13%.  The 26% required me to reboot them after 7 days. I expect that the last 26% were in our clinics and labs.  This is good information to know.  Next time I will start with the reboot and see how long the rest take.

Your results will vary.

March 5, 2010

Powershell: Move files with the pipe

Filed under: Uncategorized — Kevmar @ 6:28 am

One of the games I play has a built in screen shot capture button. Every time you press it, a jpg gets saved into the screenshot folder. I have lots of files in this folder and its hard to manage. When I am taking screen shots for a blog post on another site, I will move all that I take that day to another folder. To day I broke out the powershell to do it for me. There are many ways to do this but I was playing with using the pipeline to do things tonight and I ended up with this command:

PS> ls C:\Program Files\World of Warcraft\Screenshots\*.jpg | sort-object lastwritetime | select -last 14 | move -Destination .\BlogFolder

March 2, 2010

Powershell Grep to find old server names in batchfiles

Filed under: Script,Uncategorized — Tags: — Kevmar @ 11:40 am

I was troubleshooting a user access problem today and found that they had a old mapping to an old server in the login script.  We just moved all our data to a different server so it was expected to have a few issues like this.  We do use DFS for most of our shares so the transition was very smooth for most people.  Just a few exceptions needed fixed.

I think we just over looked the log in scripts so I needed a script to check them all.  This is where I should just use grep but I wanted to see how to do it in powershell.  Here is the command I came up with:

PS> get-childitem \\domain\netlogon -include *.bat -recurse | select-string "oldserver"

Here is another way to do the same thing with a few shorcuts that could be easier to remember at the command line:

PS> cd \\domain\netlogon
PS> dir -recurse | select-string "oldserver"

dir is short for get-childitem.  If all you have are .bat files in netlogon you can skip the include.  If you have other install files or packages, use the include to save time.

February 27, 2010

Powershell replaced my favorite DOS command

Filed under: Uncategorized — Kevmar @ 11:52 am

My favorite dos shell command is the for loop.  I have used that so many time to automate things for me.

C:\> for /f %i in ('dir /b') do echo %i

I would either pipe that into a file and use it in another for loop, or replace the echo with a command.  ’dir /b’ is the most common command for me to loop on.  That lists all the files in the location but only gives the file name.  I recently discovered powershell and it has this built in with more power.

PS> dir | %{echo $_.name}

Here is the full command without the shorthand.

PS> get-childitem | foreach-object{echo $_.name}

With powershell its much easier to chain things together.  In my CMD shell I would do a for loop and dump it to a file, then i would for loop on that file to a new file.  I would repeat that to get the data the way I want for my final loop command.

Lets say all of my home folders for my users are grouped in department folders and I want to list user folders where the user is not the owner.  I’m not even sure how I would do that off the command prompt but here is how I would do it with powershell.

PS> get-childitem . | foreach-object{$_.getdirectories()} | where-object {(get-acl $_.fullname).owner -ne "domain\" + $_.name} | format-table fullname

January 21, 2010

Tower Defender

Filed under: Uncategorized — Kevmar @ 11:45 am

One of my favorite mods for Warcraft 3 was tower defender.  I remember killing lots of time on that.  Several different tower defenders were made including a 3v3 where you attacked the other side.  I don’t remember the name of that one but it added a different strategy to it.  I took it and added something special.

I added better pathing logic and a computer AI option.  I thought the pathing was an issue because people could build towers in a way that would make the mobs walk bad directions that they should not be walking.  At this point no other warcraft tower defender had a need for computer AI.

The way the pathing worked was each mob was told to got to a point, then it got to that point, it was given a new point to walk to.  From point A to B to C to D to end.  This map could have just told the mob to go to end, but it would hug the wall as it turned the corners.  Sending the mob to points that were in the middle of the walk way was better game play.  This opened up a exploit where you could block off the next point and route the mob far away from it.  The mob would follow your path, then head back to the point for its next orders.  Once it got its new point, it would walk past all your towers again.  You could walk the mob all the way to the end and let him go, and he would still travel all the way back.  His order was to go to B not the end.

I still used the points as where to walk to but added large areas that would issue new commands.  If the mob was directed past point B it would pick up the new order to go to point C even if it never made it to B.  So I gave it new orders based on what section it was in.  I moved the commands back so they go the new order before they got close to the target points.  So now the points acted as a general direction and not an exact command.

The computer AI was fun to add.  Because I wanted to keep the tower placement logic simple, I made it very aggressive on the atacks.  I would place towers at random in a fairly tight grouping.  I did not do any pathing tricks, but it got the job done.  It would place a set amount when it did place them.   The types of towers it placed depended on the funds available.  The aggressive attack is what made this work. 

The AI could send as many mobs as possible at almost the exact same time.  So the grouping was very tight for all the mobs it sent.  It also had perfect timing of when to send an attack.  It would save for a full attack at the end of a round and then release a 2nd full attack at the start of the next round.  It would blow all the gold starting with the most expensive mobs first working down.  This strat sent as many of the strongest mobs possible as early as possible.

This way is the only way to send mobs at your opponent.  If you staggered when you send them during the round, the other side would easily pick them off.  My AI would brute force and early victory.  With optimal spending every single round, the gold available out produced the person over defending. 

While it was not the best opponent, it was able to fill in when the teams were not balanced.  It made a great team member because you could fill in towers where it was weak knowing it was keeping up the attack.  You could also get a feel for its attack cycle so you could send your troops at the same time.

November 23, 2009

Creating a MST Transform from a MSI

Filed under: Uncategorized — Kevmar @ 4:24 pm

I had a vendor MSI that I needed to make changes too.  I wanted to push it out as a silent install but as it was configured, it required user input to install correctly.  I found a lot of information telling me that I needed a MSI transform (or MST) to do that.  But I found almost no details on how to create that transform.

I eventually discovered the ORCA MSI Editor.  I think its a Microsoft tool but I found it on this Technipage.  ORCA looks at the MSI like its a database and exposes all the tables and records to you.  It is a bit overwhelming to get into.  After messing up a few MSI packages (make backups first) I discovered how easy it was to create a transform. Making changes is where it gets hard.

To create a mst transform, first open the MSI. Then under Transform, choose New Transform.  Now make any changes or updates that you want to make.  When you are done, under the Transform menu choose Generate Transform and save it.  This will create a MST with your changes.  To test the transform you can run your command like this: base.msi TRANSFORMS=transform1.mst

That looks easy and once you figure out what changes you are going to make then it is easy.  Here are two links you should look at.  Using a Sequence Table  and the List of Database Tables. They were a huge help to me.  Here are a few examples of changes that I made.

The first one was to fix the message “This installation cannot be run directly launching the MSI package. You must run setup.exe“.  In the Properties table add a row called ISSETUPDRIVEN with a value of 1.  This will allow the msi to run on its own.  Remember they added this check to make sure your version of Microsoft Installer supported the MSI.  If it fails, you may have to install the correct files yourself.

My setup had one section with 3 options and I need to disable one of those options.  I tracked that option down to a entry in the Feature table.  Looking at the online documentation it looks like setting the Level value to 0 from 1 will do that for me.

Registry settings was also something I needed to mess with.  All the registry settings were in the Registry table.  I found the key I wanted to change and was able to change the value.  There was a second key I had to add in by hand.  It is one that the installer would prompt the user for and it had no default.  If I want my silent install to work, I have to make sure that value gets set.  The component column puts the key in a group that matches an installed component.  I reused the component value of the other key I changed.  I should never see one without the other.  I set Root = 2 because that’s what the other key had. 

That was all the changed I needed to make.  It was a lot to take in at first.  I had never created a MST before.  It was a great way to work around the vendor.  I know I have ran into this before where a MST was needed but I was able to just use a batchfile instead.  Now that I am running things with a bit more security with windows 7, batch files just don’t cut it anymore.

November 13, 2009

a Horse and a little buddy

Filed under: Uncategorized,Warcraft — Tags: — Kevmar @ 12:01 am

My 4 year old girl Charis has started to play Warcraft.  It is interesting watching her discover the game.  I started her out on a 63 warlock at the xroads on a mount.  She would ride all over the place.  I would let her be and after a while she would come get me for help.

I guess she likes to take the horse swimming.  Her corpse was way out in the water several times.  So told her she had to keep the horse out of the water.  Once she stopped taking him swimming, she lived a lot longer.  I also placed the mount on the action bar and showed her how to mount up on her own.penguin

Her next issue was getting inside a building and not able to mount up.  She likes to check things out. I pulled out a pet (her little buddy) and let her know she was not allowed to ride the horse inside (or in the water).  Other than getting stuck in odd places, she managed to find her way around.  One of her favorite things was ridding the blimp.  She managed to find the blimp outside org, go up the spiral stairs, wait for the blimp, and get on it.

I later showed her the mini map.  There was one point she was a ghost not far from the graveyard (i usualy just spirit rez her).  I have Carbonite installed so it draws a line on the mini map directing you where to go.  She was able to make the connection from the mini map to her character.  When there was something in her path like a tree, she would navigate around it and use the mini map to get back on track.  She was in northrend on that 63 lock so I got her back to org where it was a bit safer.

Charis, her horsey, and her little buddy are cutting into my pre raid game time a bit.  When its my turn, she sits and watches me raid a while.  I use headphones to protect her from vent though.  I need to get her set up on her own computer and get her into some more educational games.  But for now I will let her have fun with her horsey and little buddy.  Thats what she askes for when she wanted to play.  A horsey and a little buddy.

November 11, 2009

A Quick Update

Filed under: Uncategorized,Warcraft — Tags: — Kevmar @ 11:46 pm

I am still trying to work a few things out.  Im trying to consolidate my stuff better, but looking at I don’t want all of my warcraft stuff showing up on my main blog.  My last post I started out talking about herbs.  If you are thinking wow its on topic for wow stuff.  If you came to the blog from something else where wow was not on your mind and i’m talking about purchasing herbs you may want me to show up for a random drug test at work.

I have it set up that posts from one area auto show up in the other.  I just have too much getting republished.  I know I am falling behind on my posts.  I do that often, but I usualy have a large queue of stuff to cover.  So now that my queue has ran out, I am missing more posts.

I’ll get back to a schedule here before too long.

Older Posts »

Powered by WordPress