Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: shutdown after a program exits  (Read 2950 times)

0 Members and 1 Guest are viewing this topic.

canoad

  • Guest
shutdown after a program exits
« on: March 09, 2006, 02:29:45 PM »
Hi;

In XP, I want to make a batch file to run a particular program at startup and once that program has closed, I want to shutdown the system. I tried just putting those two commands in a batch file in the startup but it just run thriugh and shutdown the computer. I want it to wait until the program closes then run shut down.

Can someone help me out?

Thanks

pcdoc4christ

  • Guest
Re: shutdown after a program exits
« Reply #1 on: March 09, 2006, 06:19:00 PM »
Canoad:

In Windows XP, you may add the SHUTDOWN command to the batch file:

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 [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)


Doc

pcdoc4christ

  • Guest
Re: shutdown after a program exits
« Reply #2 on: March 10, 2006, 04:28:25 PM »
If anyone is interested, the above command in a batch file is a good way to shutdown windows with one click of the mouse (instead of the three it annoyingly takes to shutdown Windows).  Just put the shortcut to the batch file in the Quick Launch toolbar.  The shutdown command is only available in Windows XP, however.

Doc
« Last Edit: March 10, 2006, 04:30:02 PM by pcdoc4christ »

canoad

  • Guest
Re: shutdown after a program exits
« Reply #3 on: March 13, 2006, 09:12:46 AM »
Doc4Christ;

I have tried it in a batch file but unfortunetly it does not wait for the previous program to exit. It just shuts down immediately. I need to have sometype of exit code from the previous program(also in the batch file) that I can check and when it does exit then run the shutdown. Do you know of anything like that, that I can check for?

Thanks

Backdated

  • Guest
Re: shutdown after a program exits
« Reply #4 on: March 13, 2006, 12:18:26 PM »
You have to make provision for a return code or "errorlevel" as was known in DOS, ie:
if errorlevel 0 then shutdown /blah

Please give details of what programs etc.

canoad

  • Guest
Re: shutdown after a program exits
« Reply #5 on: March 13, 2006, 12:55:12 PM »
Hi;

Its a satellite PCI card and the name of the program is called MY Theater. I have it and the shutdown program in my startup folder. But I do not want to run the shutdown until I exit MY theather.


Thanks