I was asked to provide a software solution last week for work. I was like, "Sure, I can do that, no problem!" WELL....
Problem: Need a better way of transferring a Windows profile from an old machine to a new machine. Currently takes the Config team 2 to 3 hours.
Solution: Part One: Make a User application to define the Source Computer and Destination computer, define the user to transfer and create an XML file with the requested directories. File to be processed by a Windows service located on another machine.
Part Two: Create a service to run at a specific time to copy the requested folders to the new machine.
Part one was a breeze. I created a VB.Net application that can PING both machines and verifies that the profile is on the source and the "user" has logged in at least once on the new one. It loads an XML file with the directories to be processed, allows the user to remove those directories not wanted. Just a really nice app.
Part two was a monster. I knew that you could create a service in VB.Net, it was the HOW that was needed. As usual, I Googled, and googled and googled. Searching for "vb.net Windows service" was the best but not totally accurate. I tried 3 of the "samples" that I found only to figure out that as soon as I logged off, so did the code! This was not at all what I wanted. I needed a service that would run no mater who, if anyone was logged in. Three days and a few hundred lines of code later, I finally figured it out!
Turns out, System.Timers.Timer is the guy you want to use. the System.Windows.Forms.Timer will NOT work in a service. OK, I kind of expected that, so I went with System.Threading.Timer. This did not give the required response either. Then I found out about System.Timers.Timer. What a NICE control! I was able to set up the interval using the TimeSpan.TotalMilliseconds and the service Just runs!
If you are working on a VB.NET service and need a hand, let me know. I will be more than happy to assist, you can email me at WaibelOnline.com
Rob
No comments:
Post a Comment