\$\begingroup\$
\$\endgroup\$
8
This program automatically makes folders to add scripts to be ran once a computer is logged off a user. It checks to make sure it is not overwriting any previous scripts (windows).
:: Author: Brandon Finley
:: Date: 4/20/2017
:: Purpose: This program automatically makes folders to add scripts to be ran once a computer is logged off a user. It checks to make sure it is not overwriting any previous scripts
:: that may have already been created, and then adds the ChromeClear to the list. THIS PROGRAM IS A TOTAL NUKE TO THE CHROME BROWSER; IT WILL DELETE EVERYTHING!
:: If there are no previous scripts added, it needs to create the file locations to use
@ECHO OFF
IF NOT EXIST C:\Windows\System32\GroupPolicy\User MD C:\Windows\System32\GroupPolicy\User
IF NOT EXIST C:\Windows\System32\GroupPolicy\User\Scripts MD C:\Windows\System32\GroupPolicy\User\Scripts
IF NOT EXIST C:\Windows\System32\GroupPolicy\User\Scripts\Logoff MD C:\Windows\System32\GroupPolicy\User\Scripts\Logoff
:: Writes the new .bat file to clear the browsers
ECHO SET ChromeDir=C:\Users\%%USERNAME%%\AppData\Local\Google\Chrome\User Data> C:\Windows\System32\GroupPolicy\User\Scripts\Logoff\ChromeClear.bat
ECHO DEL /q /s /f "%%ChromeDir%%">> C:\Windows\System32\GroupPolicy\User\Scripts\Logoff\ChromeClear.bat
ECHO RD /s /q "%%ChromeDir%%">> C:\Windows\System32\GroupPolicy\User\Scripts\Logoff\ChromeClear.bat
:: If there are no previous scripts.ini initialized it makes the begining of the new file (creates a new scripts.ini if not already there).
IF NOT EXIST "C:\Windows\System32\GroupPolicy\User\Scripts\scripts.ini" @echo:>>C:\Windows\System32\GroupPolicy\User\Scripts\scripts.ini
FOR /f "tokens=3" %%k in ('find /c "Logoff" "C:\Windows\System32\GroupPolicy\User\Scripts\scripts.ini"') do set theLogoff=%%k
IF /I %theLogoff%==0 @echo [Logoff]>> C:\Windows\System32\GroupPolicy\User\Scripts\scripts.ini
:: Writes to the scripts.ini file, and tries to continue the script counter if previous scripts are already added (which is why it doesn't just simply start at 0, but instead counts the scripts).
FOR /f "tokens=3" %%f in ('find /c "CmdLine" "C:\Windows\System32\GroupPolicy\User\Scripts\scripts.ini"') do set isComplete=%%f
ECHO %isComplete%CmdLine=ChromeClear.bat>> C:\Windows\System32\GroupPolicy\User\Scripts\scripts.ini
ECHO %isComplete%Parameters=>> C:\Windows\System32\GroupPolicy\User\Scripts\scripts.ini
:: Deletes the .bat file at it's location.
DEL "%~f0"
200_success
146k22 gold badges192 silver badges481 bronze badges
-
3\$\begingroup\$ Welcome to StackExchange Code Review! Please review How do I ask a good Question? Specifically, it is best to explain what the code does. This is especially true in the title. It looks like you did this in the comments, but it would be best to transfer that to prose a the beginning on the post. \$\endgroup\$Stephen Rauch– Stephen Rauch2017年04月21日 16:52:47 +00:00Commented Apr 21, 2017 at 16:52
-
\$\begingroup\$ Seems like extraneous information to just copy and paste what the comments say. Please refer to the comments provided in the script as to what it does. \$\endgroup\$Brandon– Brandon2017年04月21日 16:54:31 +00:00Commented Apr 21, 2017 at 16:54
-
4\$\begingroup\$ Yes but, note that you are trying to attract peoples attention to your post so that you can get their feedback. The easier you make it for them to see if they are going to be productive in providing feedback, the more likely you will get that feedback. If they have to spend much time determining if they can help they may just move on. \$\endgroup\$Stephen Rauch– Stephen Rauch2017年04月21日 16:56:32 +00:00Commented Apr 21, 2017 at 16:56
-
1\$\begingroup\$ I guess if I don't then I just get people criticizing on the format of the question rather than the question itself. Thanks for the useful insight to this website. \$\endgroup\$Brandon– Brandon2017年04月21日 17:02:00 +00:00Commented Apr 21, 2017 at 17:02
-
2\$\begingroup\$ @Brandon I have no idea what you are talking about. \$\endgroup\$t3chb0t– t3chb0t2017年04月26日 03:58:45 +00:00Commented Apr 26, 2017 at 3:58
You must log in to answer this question.
default