If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
How to add a "Shutdown" folder (the opposite of the "startup" folder) ?
Hello all,
I would like to have a "shutdown" folder which functions in the same way as the "startup" folder does ("C:\Documents and Settings\{username}\Start Menu\Programs\Startup") (read: drop a program, batch, script, etc into the folder and it will, on shutdown, be executed). I've been looking at adding a "logoff script" (running the contents of the "shutdown" folder) using "gpedit.msc", but realised that I have no idea when that one actually runs, nor that it had its own place to store its scripts ("C:\WINDOWS\system32\GroupPolicy\User\Scripts\Log off"). And from that realised that it might perhaps be a good idea to see if someone knows a bit more about this subject - before trying to recreate something that might be build-in (but not activated) perhaps ... Regards, Rudy Wieser |
Ads |
#2
|
|||
|
|||
How to add a "Shutdown" folder (the opposite of the "startup" folder) ?
On Fri, 13 Nov 2020 10:37:58 +0100, R.Wieser wrote:
I've been looking at adding a "logoff script" (running the contents of the "shutdown" folder) using "gpedit.msc", but realised that I have no idea when that one actually runs, nor that it had its own place to store its scripts ("C:\WINDOWS\system32\GroupPolicy\User\Scripts\Log off"). And from that realised that it might perhaps be a good idea to see if someone knows a bit more about this subject - before trying to recreate something that might be build-in (but not activated) perhaps ... Pretty obvious to me based on the registry key name. |
#3
|
|||
|
|||
How to add a "Shutdown" folder (the opposite of the "startup" folder) ?
JJ,
Pretty obvious to me based on the registry key name. Yeah, I thought so too. But do you know in which order the "logon" scrips and the contents of the "startup" folder is executed - and if that makes any difference in, for example, being able to access the current users data ? And if maybe something else happens inbetween ? I don't. And thats apart from the question under who's credentials the "logon" & "logoff" scripts are run. Would not be nice when the "logoff" scripts would be run by a process with other/more permissions as the user the generated data is ment for ... But ... that all would be moot (in my current case) if the OS supports running the contents of a "shutdown" folder in the same way as it supports the "startup" folder. Any idea ? Regards, Rudy Wieser |
#4
|
|||
|
|||
How to add a "Shutdown" folder (the opposite of the "startup" folder) ?
"R.Wieser" on Fri, 13 Nov 2020 10:37:58 +0100
typed in microsoft.public.windowsxp.general the following: Hello all, I would like to have a "shutdown" folder which functions in the same way as the "startup" folder does ("C:\Documents and Settings\{username}\Start Menu\Programs\Startup") (read: drop a program, batch, script, etc into the folder and it will, on shutdown, be executed). I've been looking at adding a "logoff script" (running the contents of the "shutdown" folder) using "gpedit.msc", but realised that I have no idea when that one actually runs, nor that it had its own place to store its scripts ("C:\WINDOWS\system32\GroupPolicy\User\Scripts\Lo goff"). And from that realised that it might perhaps be a good idea to see if someone knows a bit more about this subject - before trying to recreate something that might be build-in (but not activated) perhaps ... Regards, Rudy Wieser I started with a "simple" batch file to transfer class work to and from school. I now use it to make a back up of today's changes, with the option to just back up, back up then goto sleep, backup and then shut down. if "%FTVar%"=="NapTime" GOTO NapTime if "%FTVar%."=="Krash." GOTO Krashing GOTO EGRESS :NapTime set FTVar=Egress Echo Going to Sleep rundll32.exe powrprof.dll,SetSuspendState 0,1,0 REM echo call %DrvX%:\(_GoodMorning.bat GOTO EGRess :krashing set FTVar=Egress SHUTDOWN /s /t 6 /c "It's gonna blow! Head for the hills!!!" REM GOTO EGRess :EGRess Echo %FTVar% Echo Bye! What I think you might want to do is have a "Good Night" program which calls the programs in your "shutdown" directory. To me, that seems simpler. -- pyotr filipivich Next month's Panel: Graft - Boon or blessing? |
#5
|
|||
|
|||
How to add a "Shutdown" folder (the opposite of the "startup" folder) ?
pyotr,
What I think you might want to do is have a "Good Night" program which calls the programs in your "shutdown" directory. I'm not at all sure what a "good night" program is. Somehow I get the idea that its something I should manually start. I already have that. Several programs and scripts that I can fire off by a single double-click. I really like to automate that double-click though. Its too easy to forget to do it Just compare it to making backups - those work best when they are automated. To me, that seems simpler. Not really. In my case its a bit more work upfront, but after that I can forget all about it. Though the question was more about if there might be problems with using a "logoff script" like that (including, but not only, running all programs in a folder), or, more important, if such an opposite to the "startup folder" is perhaps already available as a build in. Regards, Rudy Wieser |
#6
|
|||
|
|||
How to add a "Shutdown" folder (the opposite of the "startup" folder) ?
"R.Wieser" wrote:
I would like to have a "shutdown" folder which functions in the same way as the "startup" folder does ("C:\Documents and Settings\{username}\Start Menu\Programs\Startup") (read: drop a program, batch, script, etc into the folder and it will, on shutdown, be executed). I've been looking at adding a "logoff script" (running the contents of the "shutdown" folder) using "gpedit.msc", but realised that I have no idea when that one actually runs, nor that it had its own place to store its scripts ("C:\WINDOWS\system32\GroupPolicy\User\Scripts\Log off"). And from that realised that it might perhaps be a good idea to see if someone knows a bit more about this subject - before trying to recreate something that might be build-in (but not activated) perhaps ... There are logon and logoff scripts you can use. You want the logoff script. That runs when you logoff, not when Windows shuts down. Obviously that means you must be logged on for the logoff script to work, not just you loaded Windows and then shut it down (i.e., you never logged into your Windows account). Logon and logoff scripts are per-user functionality: they are specific to an account, and can be different or undefined for different accounts (unless you're in a domain where the policies get pushed onto your domain account no matter which one gets used). All policies are registry entries. gpedit.msc makes it easier, but you can edit the registry to add the policies -- except for those that incorporate a hash. For example, SRPs (Software Restriction Policies) will create a hash for the rule which the OS assigns to the rule at creation. The user cannot create the hash. I'm sure there are other policies like that, but I don't think logon/logoff script policies do that. From the following article: https://social.technet.microsoft.com...7itprosecurity rankin said the solution is: - Put your test code in testscript.cmd. (actually use any name you want, and it can be a .bat or .cmd file) - Copy testscript.cmd to %WINDIR%\system32\GroupPolicy\User\Scripts\Logoff (I think that's so you don't have to specify the path in the Script data item mentioned below. I would probably still specify the full patch to the script file.) - Add the following entries to your windows registery. (what he lists are entries you save in a .reg file, and then apply that REG file to change the registry entry) Windows Registry Editor Version 5.00 [HKEY_CURRENT_USER\Software\Policies\Microsoft\Wind ows\System\Scripts\Logoff\0\0] "Script"="testscript.cmd" "Parameters"="" "ExecTime"=hex(b):00,00,00,00,00,00,00,00,00,00,00 ,00,00,00,00,00 The Parameters data item would be those you pass to your script, if any. If you don't write your script to use shell parameters, you make blank (null) the value of the Parameters data item. I've seen some users state the registry key is under: HKEY_CURRENT_USER\Software\Microsoft\Windows\Curre ntVersion\Group Policy\Scripts\Logoff\0\0 ^^^^^^^^^^^^^^^^^^^^^^^^^^ Starting in Windows Vista, logon/logoff scripts will run asynchronously. That means you cannot ensure a service or other process has been unloaded when the script runs. This was changed because synchronous execution meant the scripts slowed logon or logoff. The scripts also run invisibly. You won't see a command prompt window for the shell in which the scripts run hence the only way you can determine if the script ran is to record some text into a logfile. Logoff scripts run with the privileges of the Windows account under which they are run. That is, they run under User permissions, not Administrator permissions. That means any commands you use in your logoff script that require elevated privileges won't run. If you need elevated privileges, make sure your Windows account is in the Administrators security group. While Task Scheduler lets to trigger "on logon", it doesn't have a "on logoff" event trigger. However, it does have "on session connect" and "on session disconnect". Those events happen when a user session is connected or disconnected from the local computer or from a remote computer. I've never used those before; however, I have defined scheduled tasks to trigger on events (by their ID). In Task Scheduler and when defining a new event, go to the Trigger tab and create a new trigger. Select "on an event" for the trigger. For the Source, enter USER32. For the event ID, enter 1074. https://www.manageengine.com/product...t-id-1074.html http://www.eventid.net/display.asp?e...&source=user32 Because this is a scheduled task, under its General tab you can elect the "Run with highest privileges" if the script needs it. However, just remember that you cannot directly run .bat or .cmd script files. Those are not themselves executable files. They require interpolation by a command processor, so the command you run is "cmd.exe /c script". Use double-quotes around the full path to the script file if there are spaces in the path or filename (I always use double-quotes because they can save headaches, and don't cause problems if not needed). In the Action tab, you run cmd.exe and the rest (/c script) go in the arguments field. Task Scheduler has a defect which Microsoft apparently will not address. If you want a scheduled task to run regardless who is logged into Windows, or if no one is logged in, you would select "Run whether user is logged in or not". That works with offline/local Windows accounts. Task Scheduler will ask for the login credentials under that Windows account under which you run the scheduled task. However, if you are using a Microsoft account, Task Scheduler cannot verify the login credentials (PIN) for a Microsoft account. If using a Microsoft account for your Windows login, you'll have to elect "Run only when user is logged on" (because the login credentials have already been accepted for you to login under the account this scheduled task runs). I think (but have not tested) a solution when using a Microsoft account but you want a scheduled event to run whether you're logged in or not is to change the account under which the task runs, like to SYSTEM. Your current Windows account must have admin permissions (i.e., it's in the Administrators security group) to specify SYSTEM for the account under which a scheduled task runs. |
#7
|
|||
|
|||
How to add a "Shutdown" folder (the opposite of the "startup"folder) ?
On 13/11/2020 11:56, JJ wrote:
Pretty obvious to me based on the registry key name. It's pretty obvious to me that when you shut down a machine then all processes also shuts down.Â* There is no need for stupid things like what has been suggested/asked here. |
#8
|
|||
|
|||
How to add a "Shutdown" folder (the opposite of the "startup" folder) ?
"R.Wieser" on Fri, 13 Nov 2020 18:27:43 +0100
typed in microsoft.public.windowsxp.general the following: pyotr, What I think you might want to do is have a "Good Night" program which calls the programs in your "shutdown" directory. I'm not at all sure what a "good night" program is. Good Night, going home, I'm done for the day, turn it off , unplug and go home / to bed. Whatever - it is the last set of programs run. The batch file makes a screen color change at the end and exited with the message "unplug it and go home". Somehow I get the idea that its something I should manually start. I already have that. Several programs and scripts that I can fire off by a single double-click. I really like to automate that double-click though. Its too easy to forget to do it True. Okay, so what it sounds like is you want a "hack" to the system which will run programs X, Y, and B before doing it's own version of put out the cat, turn off the lights, and wind the clock. [I rant about Windows on start up, yes, it has brought up the screen and desktop. But before I can do anything,WIndoze has to check it's email,call the wife, chat about the ball game / TV show, and get a cup of coffee before it will actually get around to being ready to work. That's why I turn it on and then go make coffee, etc.*] Sorry, can't help you there. Just compare it to making backups - those work best when they are automated. Right. And having a "routine" end of session "good night" program which I run and which then shuts the system down _works for me_. To me, that seems simpler. Not really. In my case its a bit more work upfront, but after that I can forget all about it. There it is, which is more "work up front". For me, I have the batch file with the commands in it. Though the question was more about if there might be problems with using a "logoff script" like that (including, but not only, running all programs in a folder), or, more important, if such an opposite to the "startup folder" is perhaps already available as a build in. I think the question is "How do I, the programmer, get my choices included in the shut down operations." Keep us informed on any progress. Regards, Rudy Wieser * "Ah, but still better than the God Old Days, when the boot up/ compiler / connection was so slow that not only could you make coffee while you waited, you could have gone to Columbia and picked the beans yourself." -- pyotr filipivich Next month's Panel: Graft - Boon or blessing? |
#9
|
|||
|
|||
How to add a "Shutdown" folder (the opposite of the "startup" folder) ?
Vanguard,
There are logon and logoff scripts you can use. [Snip] Yeah, that was how far I got before doubting if everything would work allright. All policies are registry entries. gpedit.msc makes it easier, but you can edit the registry to add the policies Not quite. I've been trying to do exactly that, but could not get my script run (regardles of creating the registry entries using vbscript or importing an earlier, made by gpedit, exported .REG file). gpedit would not show the created/imported entry either. .... reading the rest of your post it looks like that the presence of gpedit on my machine is the difference : Some googeling showed that there is a "scripts.ini" file in "C:\WINDOWS\system32\GroupPolicy\User\Scripts" , which /also/ holds the name and arguments of the targetted script. Some testing (many reboots) revealed that both that file as well as the registry need to have their entries present, otherwise the targetted script will not run. Alas, I'm not allowed to write to that file. There goes my idea of an easy by-script install. :-( Next stop: Checking out if "gpedit" has commandline arguments that I can use. And thanks for the detailed info. If all else fails I'll take a look at the task scheduler. Regards, Rudy Wieser |
#10
|
|||
|
|||
How to add a "Shutdown" folder (the opposite of the "startup" folder) ?
Alan,
It's pretty obvious to me that when you shut down a machine then all processes also shuts down. Don't bet on that. Not in this day and age. :-) But pray tell, what has that to do with anything ? There is no need for stupid things like what has been suggested/asked here. I think you have not quite understood the question. What do you think I was asking for ? Why would a request to have some program(s) run on shutdown be stupid ? Regards, Rudy Wieser |
#11
|
|||
|
|||
How to add a "Shutdown" folder (the opposite of the "startup" folder) ?
pyotr,
I'm not at all sure what a "good night" program is. Good Night, going home, I'm done for the day, turn it off , unplug and go home / to bed. In that case I did understand what you ment (just wasn't sure about it). Okay, so what it sounds like is you want a "hack" to the system which will run programs X, Y, and B before doing it's own version of put out the cat, turn off the lights, and wind the clock. Nope. It already can, using "gpedit" to point to a program, script or other - though "gpedit" doesn't seem to be present in all versions of XP. Right. And having a "routine" end of session "good night" program which I run and which then shuts the system down _works for me_. :-) Ofcourse. The problem is that I know myself : I will, at some time or another, simply start to forget to do that simple, just before actually shutting down, step. It also doesn't help that I've got access to several machines, which have different configurations. I think the question is "How do I, the programmer, get my choices included in the shut down operations." Not quite. I already knew that I could use "gpedit" for that. But I realised that I had (and have) no idea when those "shut down operations" get executed, and under who's credentials (and how that could bite me in the behind). Besides that, I wanted to know if the OS maybe had a the reverse of the "startup" folder available, and if so how I could activate it. Seeing the lack of response to that part of my question I think I must assume its not there. Oh well, it was a long shot. Keep us informed on any progress. Next to having created a "shutdown" folder next to the "startup" one I've placed an about 10 line VBScript (looping thru all files in the "shutdown" folder and "run"-ing them) into the "C:\WINDOWS\system32\GroupPolicy\User\Scripts\Logo ff" folder, and than selected it using "gpedit". That works. Alas, automating the whole process (creating the "shutdown" folder adding a "logoff" rule and the script) doesn't work, as adding the "logoff" rule to the registry doesn't work (on XP Pro. Does seem to work on other XP versions (the ones without gpedit) though). Regards, Rudy Wieser |
#12
|
|||
|
|||
How to add a "Shutdown" folder (the opposite of the "startup" folder) ?
"R.Wieser" on Sat, 14 Nov 2020 10:17:56 +0100
typed in microsoft.public.windowsxp.general the following: pyotr, I'm not at all sure what a "good night" program is. Good Night, going home, I'm done for the day, turn it off , unplug and go home / to bed. In that case I did understand what you ment (just wasn't sure about it). Okay, so what it sounds like is you want a "hack" to the system which will run programs X, Y, and B before doing it's own version of put out the cat, turn off the lights, and wind the clock. Nope. It already can, using "gpedit" to point to a program, script or other - though "gpedit" doesn't seem to be present in all versions of XP. Right. And having a "routine" end of session "good night" program which I run and which then shuts the system down _works for me_. :-) Ofcourse. The problem is that I know myself : I will, at some time or another, simply start to forget to do that simple, just before actually shutting down, step. It also doesn't help that I've got access to several machines, which have different configurations. I think the question is "How do I, the programmer, get my choices included in the shut down operations." Not quite. I already knew that I could use "gpedit" for that. But I realised that I had (and have) no idea when those "shut down operations" get executed, and under who's credentials (and how that could bite me in the behind). Besides that, I wanted to know if the OS maybe had a the reverse of the "startup" folder available, and if so how I could activate it. Seeing the lack of response to that part of my question I think I must assume its not there. Oh well, it was a long shot. Keep us informed on any progress. Next to having created a "shutdown" folder next to the "startup" one I've placed an about 10 line VBScript (looping thru all files in the "shutdown" folder and "run"-ing them) into the "C:\WINDOWS\system32\GroupPolicy\User\Scripts\Log off" folder, and than selected it using "gpedit". That works. Alas, automating the whole process (creating the "shutdown" folder adding a "logoff" rule and the script) doesn't work, as adding the "logoff" rule to the registry doesn't work (on XP Pro. Does seem to work on other XP versions (the ones without gpedit) though). Sounds like fun. I think the expression is "Let it be a challenge to you." B-) Regards, Rudy Wieser -- pyotr filipivich Next month's Panel: Graft - Boon or blessing? |
#13
|
|||
|
|||
How to add a "Shutdown" folder (the opposite of the "startup" folder) ?
"R.Wieser" on Sat, 14 Nov 2020 09:50:41 +0100
typed in microsoft.public.windowsxp.general the following: Alan, It's pretty obvious to me that when you shut down a machine then all processes also shuts down. Don't bet on that. Not in this day and age. :-) Which is a why I have a power board with a BRS interrupt where I can press it. Yeah, if maybe bamboozles Windows, but now it is off. -- pyotr filipivich Next month's Panel: Graft - Boon or blessing? |
#14
|
|||
|
|||
How to add a "Shutdown" folder (the opposite of the "startup"folder) ?
On 11/13/2020 2:37 AM, R.Wieser wrote:
Hello all, I would like to have a "shutdown" folder which functions in the same way as the "startup" folder does ("C:\Documents and Settings\{username}\Start Menu\Programs\Startup") (read: drop a program, batch, script, etc into the folder and it will, on shutdown, be executed). I've been looking at adding a "logoff script" (running the contents of the "shutdown" folder) using "gpedit.msc", but realised that I have no idea when that one actually runs, nor that it had its own place to store its scripts ("C:\WINDOWS\system32\GroupPolicy\User\Scripts\Log off"). And from that realised that it might perhaps be a good idea to see if someone knows a bit more about this subject - before trying to recreate something that might be build-in (but not activated) perhaps ... A few years ago I asked a related question. I wanted to know if there was a utility or method to find out what ran during system shutdown. This was inspired by all those utilities that would tell you what was run at boot time as well as return from sleep (or hibernate). I asked this because I was curious about a certain style of malware attack. Assume that a malicious code somehow enters your system. It simply puts itself on the "shutdown list" if there is such an entity. At shutdown it puts itself on the startup list(s). At next startup, it does what it wants then removes itself from the startup list(s) and adds itself to the shutdown list. Since we seem to have no way to examine the shutdown list, this code remains hidden from sight. That is unless you know how to use some utilities unknown to the vast majority of us. Further, M$ in their wisdom made .net unavailable in safe mode so a whole bunch of utilities that might have helped investigate will not work. -- Jeff Barnett |
#15
|
|||
|
|||
How to add a "Shutdown" folder (the opposite of the "startup" folder) ?
"Jeff Barnett" wrote
| Assume that a malicious code somehow enters your system. It simply puts | itself on the "shutdown list" if there is such an entity. At shutdown it | puts itself on the startup list(s). At next startup, it does what it | wants then removes itself from the startup list(s) and adds itself to | the shutdown list. As far as I know there is no such thing. Something that wants to run at reboot puts itself in the Run or RunOnce key... or the startup folder... or whatever. But there can be all sorts of tricks. A service, which is what Apple and some others like printer companies do to keep running. A scheduled task. (I've disabled that whole mess in XP but it can't be shut off in Win7.) Various shell extensions can also do sneaky things. I've made a MIME handler myself. (A protocol filter) In earlier versions of IE it intercepts all content going to IE and allows me to edit it. I oroginally made it to create a customizable filter for blocking any desired content. Only a couple of Registry settings are required. Similarly, Explorer extensions can get a lot of access by only registering themselves. They then get full access to Explorer and IE content. So anyone who's really worried should check for such things in autoruns. |
Thread Tools | |
Display Modes | |
|
|