Shutdown a PC using a BMAx or B3d proggie
Miscellaneous Forums/General Discussion/Shutdown a PC using a BMAx or B3d proggie
Hi,
Can anyone tell me the simplest way to shut down a pc using Blitz (Max or B3d please)?
Ta
IPete2.
The lazyness of the community.
Next you'll want them making you breakfast in bed or perhaps to fetch the morning paper.
Thanks very much people...
It's only because I have a potential client asking me in
MSN..
Ta.
IPete2.
I bet he has a dog that fetches everything for him.
He's probably got 20 dogs - all fetching and doing stuff for him. He's probably goes to work on a dog-pulled sled.
Why the hell would you want to shut down the machine from a piece of software? I mean, I cannot think of a single app where there is a button to shut down the computer.
ADDITION: Well, I suppose installer programs have a button to restart the machine.
hmmm,
Having NEVER done anything quite like this before will it damage any files or anything?
The guys wants his computer to automatically shut down at a particular time every night.
IPete2.
PS I did look in the code archives under misc. but completely missed this doh!
Why doesn't he get one of his dogs to do it? They do everything else for him.
The guys wants his computer to automatically shut down at a particular time every night.
Well, if that is the totality of the job he's offering, then take the money and shake your head over his cluelessness. Otherwise, point out that shutting the computer down every night is not necessary, and possibly even a bad thing.
I cannot think of a single app where there is a button to shut down the computer.
Nero has an option to shutdown the computer after it's done burning a CD/DVD. But yeah, I can't really think of a situation where its useful either.
Otherwise, point out that shutting the computer down every night is not necessary, and possibly even a bad thing.
First take his money, then write the program, then tell him that using it is probably not a good idea. :o>
You can do that with the Task Scheduler thing in Windows. It's no big deal.
Ragnar
We looked but couldnt see it..
Pete, that'll teach you to contact little Johnnie first.
Phone me, I have the code.
Nevermind - here it all is anyway:-
ExecFile "shutdown -s"
Usage: shutdown [-i | -l | -s | -r | -a] [-f] [-m \\computername] [-t xx] [-c "comment"] [-d up:xx:yy]
No args Display this message (same as -?)
-i Display GUI interface, must be the first option
-l Log off (cannot be used with -m option)
-s Shutdown the computer
-r Shutdown and restart the computer
-a Abort a system shutdown
-m \\computername Remote computer to shutdown/restart/abort
-t xx Set timeout for shutdown to xx seconds
-c "comment" Shutdown comment (maximum of 127 characters)
-f Forces running applications to close without warning
-d [u][p]:xx:yy The reason code for the shutdown
u is the user code
p is a planned shutdown code
xx is the major reason code (positive integer less than 256)
yy is the minor reason code (positive integer less than 65536)
warning: I had a lot of problems (MAVs and hangs) with such code in Delphi on win95 and 98 PCs, but that was a long time ago.
Cool!
Thanks John - I didn't think you'd want to be disturbed late last night when the question was asked of me...
Thanks guys.
I managed to get the pc to log off - Im gonna try the task scheduler again with the "Shutdown.exe" named at the right time for the event. See how that fairs.
Thanks to one and all
IPete2.
I think all you would need to do is create a .bat file with the shutdown -s command, and run that from the Task Scheduler. I've run various .bat files from the Scheduler in the past, without any problem....though never one to shut down the machine. :)
But yeah, I can't really think of a situation where its useful either.
FlashGet (a download manager) has the option which I find damn handy when I download large stuff (I miss the days when game demos were a max of 20mb...), so I just toggle the "Shutdown after Download" buttton, hit the bed, and let the PC shut itself off.
(used it all the time as a dial-up user)
You wouldn't even need Blitz to do so: simply use the 'shutdown' command utility from the windows scheduler would do the job, with 0 programming required.
Optionally use the -f flag to force it down.
If you force it, running programs will automa5tcially be end-tasked, so if you have any open documents that you didn't save, you lose all changes. Alternatively you can not force it, but in that case a program can prevent the syste, from shutting down if it has unsaved data. (you'd get a popup asking if you want to save your file)
Now, if you do a forced shutdown, you typically get a notice and a 30-second timer. you can abort a pending shutdown only by: shutdown -a from the command line.