how can i make it so that I have a windows "Guest" user that has a script run whenever…
- User
how can i make it so that I have a windows "Guest" user that has a script run whenever they log out to clear cookies, documents, desktop, etc. and reset everything?
- Assistant
You can create a Windows user account and configure a logoff script that clears cookies, documents, desktop, and resets other settings. Here are the steps:
- Create a new user account for the "Guest" user. Go to "Settings" > "Accounts" > "Family & other users" > "Add someone else to this PC", and follow the prompts to create a new account.
- Once the new user account is created, log in to that account and create a new folder somewhere on the computer where you want to store the logoff script.
- Create a new text file in the folder, and add the following commands to the file:
bash@echo off echo Clearing cookies... del /q /f "%APPDATA%\Microsoft\Windows\Cookies\*.*" echo Clearing documents... del /q /f "%USERPROFILE%\Documents\*.*" echo Clearing desktop... del /q /f "%USERPROFILE%\Desktop\*.*" echo Resetting settings... REG DELETE "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\RunMRU" /fThese commands will delete all cookies, documents, and files on the desktop, as well as reset the "Run" command history.
- Save the text file with a .bat extension (e.g., "logoff_script.bat").
- Next, open the Local Group Policy Editor by typing "gpedit.msc" in the Start menu search box.
- In the Group Policy Editor, navigate to "User Configuration" > "Windows Settings" > "Scripts (Logon/Logoff)".
- Double-click "Logoff" in the right pane to open the Logoff Properties dialog box.
- Click "Add" to open the "Add a Script" dialog box, then click "Browse" to select the logoff script you created earlier.
- Click "OK" to close the "Add a Script" dialog box, then click "OK" again to close the Logoff Properties dialog box.
Now, whenever the "Guest" user logs off, the logoff script will run and clear cookies, documents, desktop, and reset other settings.
- User
Should I also run this script at logon too? Or just at logoff?
- Assistant
It depends on your specific use case and the level of security you want to enforce on the guest user account. Running the script at logon could ensure that the user starts with a clean slate every time they log in, but it may also cause inconvenience for the user as they will need to recreate any documents, bookmarks, or settings they had before.
If you want to ensure that the guest user starts with a clean slate every time they log in, you could add the same script to the Logon Properties dialog box in the Group Policy Editor. To do this, follow steps 5-8 as outlined in the previous answer, but instead of selecting "Logoff" in step 7, select "Logon".
However, if you only want to clear out the user's data and settings when they log off, running the script only at logoff should be sufficient. This will allow the guest user to retain their data and settings during their session but ensure that nothing is saved beyond that.
In summary, it ultimately depends on your specific use case and requirements.
- User
Does this clear Chrome user account sessions too?
- Assistant
No, the script I provided earlier will not clear Chrome user account sessions automatically. Chrome user account sessions are stored in the Chrome browser's cache and data directories, which are not located in the locations that the script is targeting.
However, you can modify the script to clear the Chrome user account sessions by adding a command that deletes the contents of the Chrome cache and data directories. The location of these directories may vary depending on the version and installation directory of Chrome, but typically they can be found at the following paths:
sql%LOCALAPPDATA%\Google\Chrome\User Data\Default\Cache %LOCALAPPDATA%\Google\Chrome\User Data\DefaultHere is an example of how you could modify the script to clear the Chrome cache and data directories:
bash