Keeping Microsoft working well by cleaning up after it...

Microsoft does not manage temporary files well by default.  And even if it removes the link to the temp files when
doing a disk cleanup, it doesn't delete them.  Leaving clutter in the directories.  Perhaps the installations I've used,
and the different corporations I've worked had some policy set that didn't clean up.  But regardless, the files are often
left behind.  This batch file removes those from a test lab environment.  

The following batch file is a nested for loop.  Quite easy to construct in Linux, not so much in Microsoft.  Have found many
pages with batch files but the explanations and examples were not clear to me.   It took a bit of effort to get this working.

REM batch file with nested for loop - used to clean up several workstations
REM  cleans TEMP and TMP variable locations and gets current users
REM john meister December 2015
set logfile=c:\bin\users\2015-12-Dec-8-workstation-use.txt
REM ############# CHANGE BEFORE RUNNING #########################
ECHO =====================================================  >> %logfile%
echo %logfile%
ECHO =====================================================  >> %logfile%
echo directory listed: %DATE% - %fulltime% >> %logfile%
echo The following list is of users and applications on lab systems. >> %logfile%
ECHO ===============================================================  >> %logfile%
REM "starting loops"
FOR %%B in (
TestSystem-6A2A1
TestSystem-6A2A2
TestSystem-6A2A3
TestSystem-6A2B1
...
TestSystem-6A2K1
TestSystem-6A2K2
TestSystem-6A2M4
TestSystem-6A2L1
TestSystem-6A2L2
TestSystem-6A2L3
TestSystem-6A2N1
TestSystem-6A2N2
)  DO (
echo %%L %%B
dir "\\%%B\C$\Users\" >> %logfile%
ECHO =============================================================  >> %logfile%
dir "\\%%B\C$\Temp\*.*"
echo "removing dir Temp "
erase /F /S /Q  "\\%%B\C$\Temp\*.*"
rmdir /S /Q  "\\%%B\C$\Temp\"
echo "making dir temp "
mkdir "\\%%B\C$\Temp\"
echo "listing dir of temp"
dir "\\%%B\C$\Temp\" >> %logfile%
ECHO =============================================================  >> %logfile%
dir "\\%%B\C$\Windows\Temp\"
echo "removing dir Windows Temp "
erase /F /S /Q  "\\%%B\C$\Windows\Temp\*.*"
rmdir /S /Q  "\\%%B\C$\Windows\Temp\"
echo "making Windows temp "
mkdir "\\%%B\C$\Windows\Temp\"
echo "listing dir of Windows temp"
dir "\\%%B\C$\Windows\Temp\" >> %logfile%
ECHO =============================================================  >> %logfile%
echo next box after users
REM "next loop"
FOR %%L in (
auser596
auser597
auser638
buser421
buser183
buser999
cuser666
cuser555
....
vuser189
wuser862
xuser289
xuser340
yuser258
yuser401
zuser283
) DO (
echo %%L %%B
dir "\\%%B\C$\Users\%%L\AppData\Local\Temp\*.*"
echo "removing dir local temp "
erase /F /S /Q  "\\%%B\C$\Users\%%L\AppData\Local\Temp\*.*"
rmdir /S /Q  "\\%%B\C$\Users\%%L\AppData\Local\Temp\"
echo "making dir local temp "
mkdir "\\%%B\C$\Users\%%L\AppData\Local\Temp\"
echo "listing dir of temp"
dir "\\%%B\C$\Users\%%L\AppData\Local\Temp\*.*"
echo next user
)
)

search for:
on the internet, or:
JohnMeister.com-fotos
LinuxMeister-Linux
BibleTech- Bible overview

johnmeister.com/jeep/sj

FULL SIZE JEEPS

JeepMeister
"Jeep is America's
only real sports car."
-Enzo Ferrari


MeisterTech
Diesels +

One Page Overview

Intro to Linux


AMSOIL product guide,
or, AMSOIL web, or 1-800-956-5695,
use customer #283461

Amsoil dealer since 1983
purchase AMSOIL
at Midway Auto on SR9 in Snohomish,
or at Northland Diesel in Bellingham, WA


SJ - 1962-1991

XJ - 1984-2001

WJ - 1999-2004

KJ - 2002-2007

WK - 2005-2010

Find the recommended
AMSOIL synthetics
for your Jeep

CJ-10A - 1984-1986

Jeepsters

MJ - 1984-1992

Willys - 1946-1965

Other Jeeps (FC)