View Full Version : Run a program before fully logging off
ralxz
02-09-2006, 05:44 PM
Hey guys. I'm looking to write a progam that would backup a directory before fully logging off. The ideal possibility would be: User Clicks Logoff -> Program Runs -> Logoff completes when program exits. Do you guys know how to interrupt a logoff like this?
Thanks,
Ryan
slushy77
02-10-2006, 02:26 AM
hi Ralxz,
as I dont know whether you are using WIN, NIX or MAC, I can't give a complete solution but the principle relies on knowing the command that is executed when you logoff from the system. A search engine would provide exact details. on NIX the command for logoff is usually either 'exit' or 'logoff', on XP it looks like it might be 'shutdown' or 'logoff'. (Dont know what it is on MAC, dont have one yet :( )
you then write a batch or sh file to recursively copy user's files to the backup directory and calls the logoff command .
having written this file just create a shortcut on your desktop with a suitable icon and label.
There are probably more sophisticated methods than this, but this method is fairly straightforward and suitable for home computers.
ralxz
02-10-2006, 06:01 PM
Thanks for your response. Sorry, I should've said earlier that I was on a windows. A batch would be ideal, although could it open a program and wait for it to close before fully logging off?
Thanks,
ralxz
slushy77
02-14-2006, 02:15 AM
it is possible for a batch file to open a windows application and wait for it to terminate before executing the rest of the batch. Have a look at the help for the start command. (dos not windows), it should do what you want.
bear in mind that you would be giving a user interactive control of an automated process - not always a good idea.
SteelValor
02-14-2006, 09:36 PM
I would also suggets a batch and add something like this at the end
%windir%\system32\rundll32.exe user32.dll,LockWorkStation
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.