Link to home
Start Free TrialLog in
Avatar of Billy Morrison
Billy Morrison

asked on

user script on chrome exit.

Run a .bat script on before chrome exits.
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

Run a .bat script on before chrome exits.

I would think you need to have a "listener" program running at the background to verify if a Chrome process is running. If you have detecting it's quiting, then use that "listener" program to execute the .bat script that has been assigned.
Avatar of Dr. Klahn
Dr. Klahn

Write a script file that starts Chrome as the first thing it does.  The script file will hang while Chrome is running.  Then add the desired commands after the Chrome invocation.  When Chrome exits, the script will resume and execute the commands.

Replace the shortcut to Chrome with a shortcut to the script file.  Ugly but simple.
Really need more info about what you are trying to accomplish to comment meaningfully.  There is nothing built in to Chrome to allow this (that I know of), so it would have to be a work around of sorts.

But Chrome will start many processes when you are browsing with it, so the question is what are you trying to accomplish?  Is it when you close one tab, maybe for a certain site?  Or when all tabs are closed and a single Chrome windows closes?  Or when all Chrome windows are closed, like doing EXIT from the drop down menu?

And what do you want to happen via the BAT script?  Is it cleanup of Chrome, or downloads, or something else?


»bp
Avatar of Billy Morrison

ASKER

The whole picture : We are using  Chrome on terminal server. Users have roaming profiles.

%appdata%/chrome folder grows in size. Even after enabling settings like Ephemeral and clear history on exist.

I have PS script running hourly that clears chrome folder for each user on FS server. The scripts does bookmarks backup before clearing chrome folder for each user. After chrome folder for each user is empty the script restore bookmarks for each users.

After login, chrome shows bookmarks, only when it's executed for the first time.

This is not an ideal solution, but works.
Is there a way to clear the folder %appdata\chrome

without removing the bookmarks ?
I assume you meant "without" removing bookmarks?

If so then I don't think so.  Your approach of saving them, then deleting "all", then copying them back in is probably the best approach.

In theory you could add a lot of code to your cleanup script that only deletes each subfolder by name, and then removes only specific named files from the root, thereby leaving the bookmarks.  But that would take a lot of extra lines in the cleanup, and if folder or file names change in future releases you would need to adapt to those.


»bp
thank Bill
@Billy,

Are you all set with this now, or do you need more help?  If all set, could you please close it out now.  If you need help with the question close process take a look at:



»bp
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.