3
I have a system user that is dedicated to my work. At work I need postgres, however I don't need it anywhere else. Is there a way to start the postgres service when the user logs in and stop it when i log out?
Note that the user has no admin priveleges and i currently cannot start the service with this user account. If I have to change it it's ok, but suboptimal.
edit
During work I switch the user from work user to my normal user account. When I do this postgres should continue to run.
1Just as a sidenote: You don't need to create a batch script, just use NET as the program and START [Service Name] as parameters. – Mene – 2012-01-19T13:51:42.320
Also I used the "At log on" trigger. There's no "At log out" so I used the proposed disconnect trigger; didn't test the connect trigger. I guess both are working, but the connect/disconnect sounds more "symmetric". Wonder why there's no log off counterpart for the log in trigger – Mene – 2012-01-19T13:57:11.563
Just noticed that this is not working for me. I'd need an "At log off" trigger since I'm switching around during work and postgres should continue to work as long as I don't log off the work-user. – Mene – 2012-01-19T14:10:34.583
If you use User Switching then you will need to use the connect trigger as the disconnect is triggered when you switch away and the logon will not trigger when switching back. – Shevek – 2012-01-19T14:13:49.820
Yes, but the service will be stopped when I switch away, but it needs to be running. I usually switch when i run integration tests and I need the database for this to work. – Mene – 2012-01-19T14:19:44.583
It's a bit long winded but maybe use the
On an event
trigger to look for the log off event? but this will fire if either user logs off... – Shevek – 2012-01-19T14:28:29.373That should work under my circumstances, thanks! – Mene – 2012-01-19T16:08:41.630
For some reason the "user" filter isn't working for this; however since I only switch between two users and the "mainuser" stays logged on it's fine for me. I did use event id 7002 though - might be the reason why the user filter is not working, not sure, I found that Id on some forum before you edited your answer. When I find time I'll try 4647. – Mene – 2012-02-23T12:43:06.347