Tuesday, February 9, 2010

Week 6: Powershell Daemon

This is a program that runs a powershell script. It will put a notify icon in the task bar while the script is running. If you run a powershell script with a continuous loop in it, in order to monitor something, like the event log, this will do that without cluttering up the desktop with these "daemon" scripts. It clutters up the taskbar icons instead.

Some technical notes:

Get the powershell assembly reference from here: C:\Program Files\Reference Assemblies\Microsoft\WindowsPowerShell\v1.0

Instructions on how to run powershell from C# here: http://www.codeproject.com/KB/cs/HowToRunPowerShell.aspx

How to put a NotifyIcon in Wpf: http://www.codeproject.com/KB/WPF/wpf_notifyicon.aspx

The appropriate way to deploy this program is with ClickOnce. However, I was unable to get ClickOnce operational with this program (VS 2010). There were some cryptic notes on what could be going wrong, but the correct course of action for a lazy person, such as myself, is to wait for the next version of visual studio to come out and hope that they fix it.

Once that happens there is still something to do: Associate the *.daemon extension with this program so that double clicking a *.daemon script will launch it. This bit is simple enough to do using the registry, but I'm going to wait for the click once stuff to get straightened out before I waste time on installers.

No comments:

Post a Comment