sjn78 Posted June 16, 2004 Posted June 16, 2004 I have seen many people asking how to force a shutdown of a pc, but this is what I want to do. I'm think of writing a service that when the computer is told to turn off, the service fires up and does a backup of specified folders to another computer on the network. I am thinking of giving a message asking whether or not to do the backup and if they say yes, then do the backup then shutdown the pc, otherwise shut the machine off without the backup. Is this possible......well anything is possible if you try hard enough!! Any tips on where to look, api's etc. Quote
*Experts* Nerseus Posted June 16, 2004 *Experts* Posted June 16, 2004 I do this on my machine, but not automated when I shutdown. If most people are like me then they rarely shutdown on purpose. Home users might, but I think you're referring to "business" users. What I use is a simple batch file that runs on a schedule - every night around 2am (I think). Some files can't be backed up without shutting down applications (like my Outlook PST file), so I either remember to shut it down or it doesn't get backed up. I can't help so much for what you want, but I can offer up this: 1. Services, in general, aren't supposed to show any UI. A prompt to the user might very well go unnoticed if they hit "Shut Down" then walk away. 2. If windows is shutting down and you popup a messagebox windows might do 1 of 2 things (both bad): either shutdown your service after 10 or 30 seconds (not enough time to backup) or NEVER shutdown unless the user answers the prompt (if they walk away early, their machine doesn't shutdown). I know there's a way to setup a script to run when you log into a Domain. There *might* be a similar feature for shutting down. I'm no admin so I can't say for sure. Now, you *might* do this, if you really want it: Write an app that users use to Shutdown their PC. They'd have to be trained to NOT use the Start Menu->Shutdown, but go through your EXE. It could do whatever you want and then shutdown. You could even prompt them and wait for 30 seconds (your prompt would appear immediately). If no one answered, just shutdown. -nerseus Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
sjn78 Posted June 16, 2004 Author Posted June 16, 2004 Thanks for your input, it has given me a few more ideas on this. You were mainly talking about running this type of program for a business where I just want this for home. I have a pc, my partner has a PC and there is a spare one(the one to be used for the backups). They are all networked in the same way a business would be though, but they are turned off at night, although would need the 'backup machine' to be on all the time. I'm only looking at doing this since it's such a hassle to copy all of the files between pc's when one needs a format and this is happening on a frequent basis, about 3-6 months. But, I will take into consideration your comments and go from there. Thanks. Quote
*Experts* Nerseus Posted June 17, 2004 *Experts* Posted June 17, 2004 If it's for personal use, I can offer a suggestion: keep your "backup" files in one location. For example, I keep all my "personal" files in a folder called "myusername" on my D:\. When/if I need to reinstall windows or just backup the "good" files, they're all in one place. If they can't go there because some files live elsewhere (always possible), you might have a batch file that you update to automatically copy files to your "myusername" folder. Favorites are a good example since they live in the Documents and Settings area. For work I do something similar, but I have a whole drive set aside for the "backup" stuff. That includes my sourcecode (which has my test projects and such), sourcesafe (local copy) and downloads, among other things. To backup I need everything on that drive, plus "My Documents" and Favorites. It's generally best to keep your "list" in one place, be it a batch file, a txt document, or just a piece of paper. -nerseus Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.