Jump to content

Recommended Posts

Posted (edited)

Some of you might remember I posted in a thread about shutdowns recently, hinting about an automatic tool for CC3 networks. Well here it is, finished and tested at Nobel.

 

Network Shutdown 3 gives you the power to save energy, money and the environment by intelligently shutting down your RM network on a schedule. More efficient, less messy and faster than scripts, with a full GUI, safe list and logging. It automatically recognises your domain computers so there's no lists to maintain!

 

You can download it from here: Network Shutdown at Paul Beesley

 

I've made a real effort with this release to include thorough documentation so feedback on that is appreciated. I'm re-writing the AUP Informant and EduSweep documentation in the same format.

Edited by bizzel
  • Thanks 2
Posted

I should clarify why this is CC3 only as well. The program uses the PackageControl folder, a directory that contains .ini files for all domain desktops, to get its list of computers. That folder is only available on CC3 domain controllers.

 

At startup the program locates the domain controller automatically to perform the search. In theory this will work from any computer but I recommend running it from a server.

 

One advantage of using this method over active directory is that no servers or non-RM computers are included in the list.

 

Oh, and here's a screenshot:

 

http://www.paulbeesley.com/wp-content/uploads/2008/09/network-shutdown-3.jpg

  • Thanks 1
Posted

Couldn't people that aren't on CC3 just duplicate this folder and .ini file structure on their dc's to emulate a cc3 network so the tool will work?

 

Ben

  • Thanks 1
Posted

Or if you could see your way to including the use of a list of computers that would be cool and means everyone could use it.

 

I like the idea of wmi to check if the machine is actually on to save waiting for something that isn't going to respond.

 

Can this also be scheduled rather than run from the gui?

 

Ben

  • Thanks 1
Posted (edited)
Or if you could see your way to including the use of a list of computers that would be cool and means everyone could use it.

 

Yes, absolutely. I'm all for making it work on as many networks as possible in the long run. I originally wrote the program for our network alone and kept it as simple as possible, which is why it's using that folder.

 

If I can find a way to query active directory easily I'll add that in. For the moment I'm concentrating on EduSweep and AUP Informant but I'll investigate at the very least.

 

Can this also be scheduled rather than run from the gui?

 

Yep. There's no built-in scheduler. If you run the program it'll start the process almost immediately (you have 10 seconds to abort). It's designed to be scheduled using Windows' own task scheduler, just use it to launch the .exe. That's documented in the manual as well for reference.

 

And thanks, I thought the WMI tests were a cool idea. :tea:

Edited by bizzel
Posted
OK if you have RM I spose!

 

wtf is that supposed to mean?

 

If you ain't got anything constructive to say then don't bother the man has allready said he wants to make it work on as many systems as possible.

 

ffs.

 

Ben

Posted

Paul,

 

I ran a test today at half 3, it went a little too well catching some pupils still logged in 'working', he he... Now scheduled the task for a little later in the evening.

 

It only work on the FRDC, tested on two other DCs (inc the one with the packages) but it couldnt find the package list of those.

 

Cheers

Posted

I presume with wmi you can also check to see if anyone is logged in but then you would have to run it later a second time anyway to catch any that were logged on the firstime.

 

Unless using wmi you can schedule the shutdown on the local machine for later?

 

Ben

Posted (edited)
I presume with wmi you can also check to see if anyone is logged in but then you would have to run it later a second time anyway to catch any that were logged on the firstime.

 

Unless using wmi you can schedule the shutdown on the local machine for later?

 

Ben

 

I was also working on a simmilar bit of code that integrated into a larger program, here is some code that returns both the currently logged on user and how long the machine has been running. My code was to institute a safe list of users as well who would not be kicked off as well as ones that would be kicked off after a certain time.

 

        private void button1_Click(object sender, EventArgs e)
       {//timespan object to store the result value
           TimeSpan uptimeTs = new TimeSpan();
           ManagementScope theScope = new ManagementScope("\\\\" + textBox3.Text); //computer name

           ObjectQuery theQuery = new ObjectQuery("SELECT username FROM Win32_ComputerSystem");

           ManagementObjectSearcher theSearcher = new ManagementObjectSearcher(theScope, theQuery);

           ManagementObjectCollection theCollection = theSearcher.Get();

           foreach (ManagementObject theCurObject in theCollection)
           {
               textBox1.Text = theCurObject["username"].ToString(); //output currently logged on user
           }
           theQuery.QueryString = "SELECT LastBootUpTime FROM Win32_OperatingSystem";

           theSearcher.Query = theQuery;

           theCollection = theSearcher.Get();

           foreach (ManagementObject theCurObject in theCollection)
           {
               DateTime lastBootUp;

               DateTime date = DateTime.MinValue;
               string wmiDate;
               //check date integrity 
               wmiDate = theCurObject["LastBootUpTime"].ToString();
               if (wmiDate != null && wmiDate.IndexOf('.') != -1)
               {
                   //obtain the date with miliseconds 
                   string tempDate = wmiDate.Substring(0, wmiDate.IndexOf('.') + 4);

                   //check the lenght 23 if (tempDate.Length == 18) 
                   {
                       //extract each date component 
                       int year = Convert.ToInt32(tempDate.Substring(0, 4));
                       int month = Convert.ToInt32(tempDate.Substring(4, 2));
                       int day = Convert.ToInt32(tempDate.Substring(6, 2));
                       int hour = Convert.ToInt32(tempDate.Substring(8, 2));
                       int minute = Convert.ToInt32(tempDate.Substring(10, 2));
                       int second = Convert.ToInt32(tempDate.Substring(12, 2));
                       int milisecond = Convert.ToInt32(tempDate.Substring(15, 3));

                       //compose the new datetime object 
                       lastBootUp = new DateTime(year, month, day, hour, minute, second, milisecond);
                       if (lastBootUp != DateTime.MinValue)
                           //get the diff between dates
                           uptimeTs = DateTime.Now - lastBootUp;
                       textBox2.Text = uptimeTs.Days.ToString() + "d " + uptimeTs.Hours.ToString() + "h " + uptimeTs.Minutes.ToString() + "m " + uptimeTs.Seconds.ToString() + "s ";
                   }
               }


               {

               }

           }
       }

It is quite rough as I got distracted but it should work. I also usually just grab a list of the currently active machines from the network browser service which prevents having to cycle through every machine even if it is not on. I can dig up that code to if you are interested.

Edited by SYNACK
  • Thanks 1
Posted
I presume with wmi you can also check to see if anyone is logged in but then you would have to run it later a second time anyway to catch any that were logged on the firstime.

 

I did have reports earler of it shutting down 'live' machines....

Posted
If I can find a way to query active directory easily

 

you could run a batch file to export a list of computes on a schedule, it will put them into a text file then get the program to read the text file.

Posted
Paul,

 

I ran a test today at half 3, it went a little too well catching some pupils still logged in 'working', he he... Now scheduled the task for a little later in the evening.

 

It only work on the FRDC, tested on two other DCs (inc the one with the packages) but it couldnt find the package list of those.

 

Cheers

 

Yep, it is pretty indiscriminate. Again, something to work on. I found a bug that can stop the packagecontrol folder being detected by other machines and will roll a fix out soon.

Posted

I tried this today running it from one of my CC3 servers, and it just hung for over 20 mins searching for stations. I know some were switched on and our network may not be perfect, but it's not that slow. Is there anything that may be causing that behaviour that I can remedy?

 

Mike.

Posted
I tried this today running it from one of my CC3 servers, and it just hung for over 20 mins searching for stations. I know some were switched on and our network may not be perfect, but it's not that slow. Is there anything that may be causing that behaviour that I can remedy?

 

Mike.

 

The station search uses the WMI ping command on every station in the PackageControl folder. The timeout for each station is about 3 seconds. If you have many stations and almost all of them are off it'll take longer but not 20 minutes.

 

Did the progress bar move at all in that time? If not, it's hung before detecting online stations.

Posted
The station search uses the WMI ping command on every station in the PackageControl folder. The timeout for each station is about 3 seconds. If you have many stations and almost all of them are off it'll take longer but not 20 minutes.

 

Did the progress bar move at all in that time? If not, it's hung before detecting online stations.

 

Yes the progress bar did move, but it had only got to about half way after 20mins, and I wasn't prepared to wait much longer as it's quicker to shut them down using RM if it's going to take that long. There could be a large number of workstations in our package control that no longer exist, my AD is littered with them as our CC3 network is very old and has seen many many different network managers in its time. Maybe if I spend a little time tidying I might have more success!

 

Thanks

 

Mike.

Posted
Yes the progress bar did move, but it had only got to about half way after 20mins, and I wasn't prepared to wait much longer as it's quicker to shut them down using RM if it's going to take that long. There could be a large number of workstations in our package control that no longer exist, my AD is littered with them as our CC3 network is very old and has seen many many different network managers in its time. Maybe if I spend a little time tidying I might have more success!

 

Thanks

 

Mike.

 

Okay Mike, thanks. At least I know it's not stalling totally. Yes, non-existent workstations will slow down the process quite a bit. I think I know a way to cut these times down by 4-5x though.

 

Although this is version 3 in name, it's only version 1 technically. Versions 1 and 2 were made by the guy who worked here before me and this is a ground-up rewrite. There are lots of improvements to come. :)

Posted
You guys never heard of shutdown.exe??

I use this integrated into a batch script, which runs as a scheduled task on our servers. It runs at 10pm, (when school closes) so no-one should be here then, and if they are: TOUGH!

 

Yes, but doing it that way relies on an up-to-date list of computer names in the batch file. I add and remove workstations to and from my network on a daily basis so this would be near enough impossible to keep up to date, I also have well over 400 workstations so the list would be long.

 

The brilliant thing about bizzels program is it's ability to use the RM ini files as a station list so a) any new workstations are automatically added, and b) I don't accidently shutdown my servers or staff workstations. For me (when I eventually get it to work that is) it provides the ideal solution.

 

Mike.

Posted

Let's start with a nice bugfix release later this week. I've fixed the problem with the packagecontrol folder not being found, now to look at the slow scanning.

 

I'm also prepping a slightly newer release of EduSweep as well.

Posted
You guys never heard of shutdown.exe??

I use this integrated into a batch script, which runs as a scheduled task on our servers. It runs at 10pm, (when school closes) so no-one should be here then, and if they are: TOUGH!

 

You have read the rest of this thread, right? :rolleyes:

Posted

I don't have daily updates of machines on my network, plus I do the install of all new machines, so is easy to add/remove machines from the list.

 

I had a script somewhere which used to query AD for computer objects, and pipe the results to a text file. I then used to paste this into excel, and add the shutdown part of the script to the computer name, then just dumped the completed results back into a text file saved as a batch file.

 

I nearly got round to totally automating the whole process...

Posted

Gosh documentation that exists! It's nicely presented and readable.. the only thing I'd add is a DNS caution (names need to point to the right addresses etc.)

 

Re. the potential future features emerging above, haven't done shutdowns but I nailed down most of that territory way back (recent example is whoison CL util in the Downloads forum). Best advice I can offer: Network scanners always need to be multi-threaded to get around latency (RPC timeouts being the worst offender in this specific case). It's worth going the extra mile when writing such code so you can easily reuse it for anything you want done to multiple boxes via the network.

  • Thanks 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...