Results 1 to 8 of 8
  1. #1
    New Lounger
    Join Date
    May 2015
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post Automated Windows batch cleaning

    Hello World!

    I work in a School Environment where the computers get stuffed with temp files and profiles of the students. So before the IT used to run programs like Ccleaner on the computers but i wanted to brag a little and make it a little easier. So i made this batch file to clean the computer. The "how it works - what it does" is explained in the code itself. If you screw up your computer with this, im not taking responsibility. It its designed for my work but i wanted to share it with yall and hear out the possible suggestions what to add in the script. This script has extended many lives of computers at my work.

    The original version consist 4 different scripts but im just posting the main 2 scripts.

    Original files:
    ManualSRP.vbs
    SuperSpeedBatch.bat
    Student.bat
    Staff.bat

    Posted files:
    ManualSRP.vbs
    Student.bat *named as "SuperSpeedBatch.bat"


    The original idea was that the files were in a folder called SSB in my pendrive and i would run only the superspeedbatch and decide there is it a staff or student computer and then it will start the correct batch accordingly... Then it would copy all to the desktop so you can extract the USB. If yall want the rest of the files, tell me.

    Remember to rename files,
    ManualSRP.txt to *.vbs
    SuperSpeedBatch.txt to *.bat


    PLS do comment and leave yar improving suggestions etc. Its a neverending work that im making better everyday.SuperSpeedBatch.txtManualSRP.txt

  2. #2
    Super Moderator BATcher's Avatar
    Join Date
    Feb 2008
    Location
    A cultural area in SW England
    Posts
    3,421
    Thanks
    33
    Thanked 195 Times in 175 Posts
    You've obviously had a lot of fun with your BATch file, and although there's a whole bunch of stuff in there I'd never dream of doing, it obviously works for you!

    I have a minor point:
    * determining OS and bit-ness might be easier if you simplify your tests like in the following:
    Code:
    @echo off
    title %~n0
    :: +----------+
    :: I OSandBit I  determine which OS is being run, and its bit-ness
    :: +----------+
    ::               also see WhichOS.bat for earlier tests
    setlocal
    ::--------------------
    :: obtain the operating system major and minor version from VER
    ::   which gives      Microsoft Windows [Version maj.min.build]
    ::   except for XP,   Microsoft Windows XP [Version maj.min.build]
    VER
    for /f "tokens=4-6 delims=[XP.] " %%a in ('ver') do set mmb=%%a.%%b.%%c
    ECHO %mmb%
    :: set the operating system name from that information
    if "%mmb:~0,3%"=="5.0"      (set opsys=Win2K)
    if "%mmb:~0,3%"=="5.1"      (set opsys=WinXP)
    if "%mmb:~0,3%"=="5.2"      (set opsys=WS2003)
    if      "%mmb%"=="6.0.6000" (set opsys=Vista) 
    if      "%mmb%"=="6.0.6001" (set opsys=WS2008) 
    if      "%mmb%"=="6.0.6002" (set opsys=WS2008R2) 
    if "%mmb:~0,3%"=="6.1"      (set opsys=Win7)
    if "%mmb:~0,3%"=="6.2"      (set opsys=Win8)
    if "%mmb:~0,3%"=="6.3"      (set opsys=Win81)    & :: needs verifying!
    if "%mmb:~0,3%"=="10."      (set opsys=Win10)
    if not defined opsys        (set opsys=unknown)
    :: I don't have any other operating systems on which to test!
    ECHO %opsys%
    ::--------------------
    :: determine if the operating system is 32-bit or 64-bit
    :: a more complex method could be (x86 test MUST be first):
    ::   if /i "%PROCESSOR_ARCHITECTURE"=="x86"   set bits=32
    ::   if /i "%PROCESSOR_ARCHITECTURE"=="AMD64" set bits=64
    ::   if /i "%PROCESSOR_ARCHITEW6432"=="AMD64" set bits=64
    :: easiest test follows
    if defined ProgramFiles(x86) (set bits=64) else (set bits=32)
    ECHO %bits%-bits
    ::--------------------
    PAUSE
    endlocal
    Many of the ECHOs are just for debugging.
    Last edited by BATcher; 2015-05-15 at 14:49.
    BATcher

    Time prevents everything happening all at once...

  3. #3
    WS Lounge VIP
    Join Date
    Dec 2009
    Location
    Earth
    Posts
    8,203
    Thanks
    49
    Thanked 989 Times in 919 Posts
    On my Win 8.1 "ver" gets: Microsoft Windows [Version 6.3.9600]

    cheers, Paul

  4. #4
    New Lounger
    Join Date
    May 2015
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thanks

    Quote Originally Posted by BATcher View Post
    You've obviously had a lot of fun with your BATch file, and although there's a whole bunch of stuff in there I'd never dream of doing, it obviously works for you!

    I have a minor point:
    * determining OS and bit-ness might be easier if you simplify your tests like in the following:
    Code:
    @echo off
    title %~n0
    :: +----------+
    :: I OSandBit I  determine which OS is being run, and its bit-ness
    :: +----------+
    ::               also see WhichOS.bat for earlier tests
    setlocal
    ::--------------------
    :: obtain the operating system major and minor version from VER
    ::   which gives      Microsoft Windows [Version maj.min.build]
    ::   except for XP,   Microsoft Windows XP [Version maj.min.build]
    VER
    for /f "tokens=4-6 delims=[XP.] " %%a in ('ver') do set mmb=%%a.%%b.%%c
    ECHO %mmb%
    :: set the operating system name from that information
    if "%mmb:~0,3%"=="5.0"      (set opsys=Win2K)
    if "%mmb:~0,3%"=="5.1"      (set opsys=WinXP)
    if "%mmb:~0,3%"=="5.2"      (set opsys=WS2003)
    if      "%mmb%"=="6.0.6000" (set opsys=Vista) 
    if      "%mmb%"=="6.0.6001" (set opsys=WS2008) 
    if      "%mmb%"=="6.0.6002" (set opsys=WS2008R2) 
    if "%mmb:~0,3%"=="6.1"      (set opsys=Win7)
    if "%mmb:~0,3%"=="6.2"      (set opsys=Win8)
    if "%mmb:~0,3%"=="6.3"      (set opsys=Win81)    & :: needs verifying!
    if "%mmb:~0,3%"=="10."      (set opsys=Win10)
    if not defined opsys        (set opsys=unknown)
    :: I don't have any other operating systems on which to test!
    ECHO %opsys%
    ::--------------------
    :: determine if the operating system is 32-bit or 64-bit
    :: a more complex method could be (x86 test MUST be first):
    ::   if /i "%PROCESSOR_ARCHITECTURE"=="x86"   set bits=32
    ::   if /i "%PROCESSOR_ARCHITECTURE"=="AMD64" set bits=64
    ::   if /i "%PROCESSOR_ARCHITEW6432"=="AMD64" set bits=64
    :: easiest test follows
    if defined ProgramFiles(x86) (set bits=64) else (set bits=32)
    ECHO %bits%-bits
    ::--------------------
    PAUSE
    endlocal
    Many of the ECHOs are just for debugging.
    Yes ill have to see to that! I've tried my best to avoid IF in the batch. But still have gave an thought about setting variables in the start of the batch and then running script parts with if. Any ideas to recognize if the computer has an SSD installed via cmd to put in a variable`?

  5. #5
    Super Moderator satrow's Avatar
    Join Date
    Dec 2009
    Location
    Cardiff, UK
    Posts
    4,492
    Thanks
    284
    Thanked 577 Times in 480 Posts
    Quote Originally Posted by Lari Harjunen View Post
    Any ideas to recognize if the computer has an SSD installed via cmd to put in a variable`?
    I'm not sure if any methods are 100% reliable, many vary across the different OSs, others are SSD vendor reliant, too many 'if's 'and's and 'but's.

    If there was a reliable method of detecting random read speed (8MB/s+ for SSD) or rotation speed (0 for SSD), they would probably be the best methods. Have you tested the method in the 2nd comment here: https://www.autoitconsulting.com/sit...sing-a-script/ ?

  6. #6
    jwoods
    Guest
    Quote Originally Posted by Lari Harjunen View Post
    PLS do comment and leave yar improving suggestions etc. Its a neverending work that im making better everyday.
    Instead of using batch files, you might take a look at the built-in command line version of the Windows Disk Cleanup utility cleanmgr.exe. In addition to the /sageset and /sagerun options, it can also be run as a scheduled task.

    http://www.thewindowsclub.com/automa...tility-windows
    Last edited by jwoods; 2015-05-18 at 14:54.

  7. #7
    New Lounger
    Join Date
    May 2015
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hey!

    Satrow, yes I have been searching for a way to find the rotation speed and save it as variable, still no luck! I really dont want to use external programs for this. Trying to keep files in minimum! Or then ill have to consider making one big exe....

    jwoods, the reason for the batch is to make it simple one-click operation that does everything for me. cleanmgr doesnt do enough and is not configurable, even though i could set it to run still in the batch. Dont know is there really idea running it to addition of the other things..

  8. #8
    Silver Lounger RolandJS's Avatar
    Join Date
    Dec 2009
    Location
    Austin metro area TX USA
    Posts
    1,735
    Thanks
    95
    Thanked 130 Times in 127 Posts
    OP's batchfile can be copied into the Startup folder of Windows, making it automatically run every time Windows fires up. And, it can be activated on-demand; that's why I also use several inf-gathering/info-textfiling batchfiles. Kudos to the OP!
    "Take care of thy backups and thy restores shall take care of thee." Ben Franklin revisited.
    http://collegecafe.fr.yuku.com/forum...-Technologies/

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •