View Full Version : run bat file at shutdown
jonnyw
08-05-2003, 07:59 AM
Is it possible to get windows to run a bat file, before it does anyhting else, whenever the computer is shutdown.
Can you guess what i'm getting at :)
thats right, i want this bat file to delete foldtrajlite.lock before it does anything else when shutdown is selected.
any ideas, or am i gonna have to write a bat file that removes the foldtrajlite.lock file and then waits, and then shuts down?
The first idea is my prefernece (to run a bat file before doing anything else)
rshepard
08-05-2003, 08:19 AM
try this: http://www.webattack.com/get/lastchance.shtml
you should be able to write your batch file, hook it to this, and you're done :thumbs:
jonnyw
08-05-2003, 11:05 AM
cheers, it seems to take me to a login screen when i use this though.
Never mind, i'll either stop being lazy and continue right clicking on dfGUI > exit
or write a bat file to delete foldtrajlite.lock and then call the shutdown -s command.
Thanks anyway for such a quick response :)
Dyyryath
08-05-2003, 12:07 PM
Heh, great minds think alike. I just finished adding a startup & shutdown script under Linux to handle starting & stopping my DF clients gracefully. ;)
jonnyw
08-05-2003, 12:10 PM
Originally posted by Dyyryath
Heh, great minds think alike. I just finished adding a startup & shutdown script under Linux to handle starting & stopping my DF clients gracefully. ;)
wont argue with that :D
am gonna be installing linux soon so will probably ask for some help in making similar scripts when I do :)
Welnic
08-05-2003, 04:00 PM
For running with Windows I sure like running dFold as a service, and it takes care of shutting it down.
bwkaz
08-05-2003, 06:47 PM
Originally posted by jonnyw
am gonna be installing linux soon so will probably ask for some help in making similar scripts when I do :) Here you go. If your distro uses SysV init (basically, everything except for Slackware does), then put this file into /etc/rc.d/init.d, call it "folding" (or whatever), and symlink to it from the runlevel directories. If that doesn't make any sense, then look for a distro tool (like ksysvinit, or RedHat's service) to set things up for you. The stuff in bold needs to be changed depending on where you installed the DF client to, and which terminal you want to run it on (I use 11, so that Ctrl-Alt-F11, or Alt-F11 if X isn't running, will switch to the DF screen).
#!/bin/sh
dfdir=/home/bilbo/distribfold
case $1 in
start)
echo -n "Starting the Distributed Folding client..."
cd $dfdir
./foldit </dev/tty11 >/dev/tty11 &
if [ $? -eq 0 ] ; then
echo " OK"
else
echo " FAILED"
fi
;;
stop)
echo -n "Stopping the Distributed Folding client..."
rm -f $dfdir/foldtrajlite.lock
while ps -C foldtrajlite >/dev/null 2>&1 ; do
sleep 1
done
echo " OK"
;;
esac
jonnyw
08-06-2003, 03:08 AM
excellent, cheers for that
all i need know is to get a new hard drive, and linux installed:mouserun:
the-mk
08-09-2003, 04:39 PM
:notworthy bwkaz :notworthy
Your init.d-script works great!
It's the best way to prevent my linux machine running idle after a power outage
:thumbs: :cheers:
bwkaz
08-09-2003, 06:18 PM
Uhh, thanks! :blush:
I think I've posted it before (or maybe a previous incarnation of it), I just don't remember where those threads would be. Ah well.
I wrote it (well, version 1 of it ;)) after installing LFS. I needed a way to start it automatically, other than running it from rc.local, which was the way I used to do it in Mandrake. I had just figured out how LFS's init system worked (the "functions" script, and the "evaluate_retval" function, among other things), so mine does look a bit different, but it's effectively the same. I decided it'd be better to make it its own script, for some reason I don't remember at the time (probably because making it separate would let me shut it down). A bit of shell programming later, and it actually worked, go figure. ;)
Powered by vBulletin® Version 4.2.4 Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.