Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

preventive maintenance scripts help


  • Please log in to reply
9 replies to this topic

#1 Joeykong

Joeykong

  • Members
  • 24 posts
  • OFFLINE
  •  
  • Local time:07:39 AM

Posted 01 October 2016 - 12:59 PM

i work in the IT department at a large car dealership (400+ computers )so i posted awhile ago on here about this and iv gotten pretty good with scripts (ill post the ones i use below )but there is a few things im struggling with 

 

so what i do is plug my flash drive in go to my PM folder and run the copy script .bat (that works fine )

it creates a folder on the C drive called PM i go to the folder and it has the scripts i want copied to it 

@@echo off
REM Check if 32 or 64-bit OS
if "%Processor_Architecture%"=="" goto oscheck
if "%Processor_Architecture%"=="x86" goto x86
if "%Processor_Architecture%"=="AMD64" goto x64
 
 
:x86
mkdir c:\PM
copy getsysteminfo.bat c:\PM\
copy cctest.bat c:\PM\
copy creatautoclean.bat c:\PM\
copy reboot.bat c:\PM\
copy autoreboot.bat c:\PM\
 
 
copy "links\Driver's Village IT Support.url" "%userprofile%\Desktop"
copy "links\dms2.0.url" "%userprofile%\Desktop"
copy "links\DMS2.0.url" "%userprofile%\Desktop"
 
 
 
 
:x64
mkdir c:\PM
copy getsysteminfo.bat c:\PM\
copy cctest.bat c:\PM\
copy creatautoclean.bat c:\PM\
copy reboot.bat c:\PM\
copy autoreboot.bat c:\PM\
 
 
copy "links\Driver's Village IT Support.url" "%userprofile%\Desktop"
copy "links\dms2.0.url" "%userprofile%\Desktop"
copy "links\DMS2.0.url" "%userprofile%\Desktop"
 
echo Everything was copied to \PM to be ran
pause
 

 

from there i have 5 scripts 

the auto reboot" Schtasks /create /SC DAILY /TN "autoreboot" /TR "C:/PM/reboot.bat" /ST 21:00"

pause
that bassically makes a task to run my reboot script every night at 9PM " c:\windows\system32\shutdown -r -t 00"
that works fine for the most part
 
then i have the create auto clean and cc test scripts "Schtasks /create /SC DAILY /TN "cleanpc" /TR "C:/PM/cctest.bat" /ST 09:00
pause"  that creates a task to run cctest.bat at 9AM every day "    
"@echo off
cd C:\Program Files\CCleaner\CCleaner.exe
start CCleaner.exe /AUTO
exit"
 
 
now that one works mostly but we have upgraded alot of pc's to windows 10 when doing that it removes ccleaner if its not updated so to fix it you just gotta reinstall ccleaner .... so i thought i noticed wile doing other things on pc's that the ccleaner tasks hasnt ran so i try running create autoclean as admin hit Y to recreate the task and get a "cannot fine specified file"
 
i cant seem to figure out the problem 
 
so that is the 1st thing i need help with 
 
 
 
the 2nd issue is i have another script called get system info (this gathers selected info and exports it to a txt file ) recently i added a section to have it continuously ping and export the results to the same text file that works fine but what i want it to do is ping continuously for 1 min (or 2-3 not sure yet ) then after that close the script or say its done hit any key to continue  iv tried alot of things with no luck here is the script 
 
 
 
 
@echo off 
echo Checking your system infor, Please wating... 
systeminfo | findstr /c:"Host Name">>C:\PM\%COMPUTERNAME%.txt 
systeminfo | findstr /c:"Domain">>C:\PM\%COMPUTERNAME%.txt
systeminfo | findstr /c:"OS Name">>C:\PM\%COMPUTERNAME%.txt 
systeminfo | findstr /c:"OS Version">>C:\PM\%COMPUTERNAME%.txt 
systeminfo | findstr /c:"System Manufacturer">>C:\PM\%COMPUTERNAME%.txt 
systeminfo | findstr /c:"System Model">>C:\PM\%COMPUTERNAME%.txt 
systeminfo | findstr /c:"System type">>C:\PM\%COMPUTERNAME%.txt 
systeminfo | findstr /c:"Total Physical Memory">>C:\PM\%COMPUTERNAME%.txt
ipconfig | findstr IPv4>>C:\PM\%COMPUTERNAME%.txt
dir -d C:\users\%username%\Desktop\ | findstr "dvrb*">>c:\PM\%COMPUTERNAME%.txt
dir -d C:\users\%username%\Desktop\ | findstr "DVRB*">>c:\PM\%COMPUTERNAME%.txt
echo.
 
echo Hard Drive Space: 
wmic diskdrive get size>>C:\PM\%COMPUTERNAME%.txt
 
echo. 
echo.
 
echo Service Tag: 
wmic bios get serialnumber>>C:\PM\%COMPUTERNAME%.txt
 
echo. 
echo. 
echo CPU: 
wmic cpu get name>>C:\PM\%COMPUTERNAME%.txt
 
findstr "dvrb*" "C:\Users\%username%\AppData\Roaming\DealerTrack DMS\DeviceConfig.txt\" >> "c:\PM\%COMPUTERNAME%.txt"
findstr "DVRB*" "C:\Users\%username%\AppData\Roaming\DealerTrack DMS\DeviceConfig.txt\" >> "c:\PM\%COMPUTERNAME%.txt"
pause
 
 
 
 
 
 
 
 
echo Completed! Thank you!
 
pause
 
@echo off 
echo ping for 1 min
Ping www.google.com -t>>C:\PM\%COMPUTERNAME%.txt
 
 
 
 
now one thing i find strange if i take just the ping section of that script and make a separate bat file it wont work it sits there and all it exports to the txt file is "ping for 1 min " over and over again i cant understand why it wont export the ping results ( i figured i make a separate script to test the ping with a set time so it wont take as long to test ) 
 
 
there are a few other scripts im working on (when a certain service is stopped it is logged in event viewer i want it to run a scheduled task to a script to restart that service)(in event viewer there is a option when you click on that event to "create scheduled task for this event) i kinda got that working but i want to make it wait 30 seconds before running the task/script because when i tested it (set up task and script ... then i went to services and ended the selected service...it seemed like wile the service was still ending it triggered the task to run the script and it came up with a error not sure what it said i should have taken a picture of it )  ... so basically what i want to do is when event view says hey this service stopped i want it to wait 30 seconds after that then run the script to restart the task 
net start "insert service name here"
 
 
 
so yea im guessing the are most likely pretty simple fixes but like i said before im getting better at scripts but im no expert 
 
thank you in advanced for any help 
 
 
 
 


BC AdBot (Login to Remove)

 


#2 random/random

random/random

  • Malware Response Team
  • 2,704 posts
  • OFFLINE
  •  
  • Gender:Male
  • Local time:07:39 AM

Posted 10 October 2016 - 06:02 AM

 

now one thing i find strange if i take just the ping section of that script and make a separate bat file it wont work it sits there and all it exports to the txt file is "ping for 1 min " over and over again i cant understand why it wont export the ping results ( i figured i make a separate script to test the ping with a set time so it wont take as long to test )

 

I believe this will be because you saved the script as ping.bat - the batch file ends up calling itself instead of ping.exe



#3 JohnnyJammer

JohnnyJammer

  • Members
  • 1,117 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:QLD Australia
  • Local time:04:39 PM

Posted 10 October 2016 - 06:20 PM

I have cleaned the script up, add the extras i left out but never do the systeminfo command like 8 times mate, would take for ever.

@echo off
::Check if 32 or 64-bit OS (Not sure why you even have this here?
copy "links\Driver's Village IT Support.url" "%userprofile%\Desktop"
copy "links\dms2.0.url" "%userprofile%\Desktop"
copy "links\DMS2.0.url" "%userprofile%\Desktop"
::Reboot PC at 9
Schtasks /create /SC DAILY /TN "autoreboot" /TR "C:/PM/reboot.bat" /ST 21:00"

::Clean Internet Explorer of all cookies and temp files
RUNDLL32.EXE inetcpl.cpl,ClearMyTracksByProcess 8

::Now run Cleanmanager using the verylow disk switch
cleanmgr /verylowdisk

:: get syustem information
::Do the Systeminfo command once as its 10 times faster, then read the txt file for info
systeminfo >> %temp%\PCStats.txt
type %temp%\PCStats.txt | find /i "Host Name" >> C:\PM\%COMPUTERNAME%.txt
type %temp%\PCStats.txt | find /i "Domain" >> C:\PM\%COMPUTERNAME%.txt
type %temp%\PCStats.txt | find /i "OS Name" >> C:\PM\%COMPUTERNAME%.txt
type %temp%\PCStats.txt | find /i "OS Version" >> C:\PM\%COMPUTERNAME%.txt
type %temp%\PCStats.txt | find /i "System Manufacturer" >> C:\PM\%COMPUTERNAME%.txt
type %temp%\PCStats.txt | find /i "System Model" >> C:\PM\%COMPUTERNAME%.txt
type %temp%\PCStats.txt | find /i "System type" >> C:\PM\%COMPUTERNAME%.txt
type %temp%\PCStats.txt | find /i "Total Physical Memory" >> C:\PM\%COMPUTERNAME%.txt
::Now lets use WMIC
wmic nicconfig where dhcpenabled="true" get ipaddress, dhcpserver, dnsdomain >> C:\PM\%COMPUTERNAME%.txt
wmic diskdrive get size >> C:\PM\%COMPUTERNAME%.txt
wmic bios get serialnumber >> C:\PM\%COMPUTERNAME%.txt
wmic cpu get name>>C:\PM\%COMPUTERNAME%.txt
::Finished
ECHO System Cleanup Complete.......
ECHO Closing in 5 seconds.....
ping -n 5 127.0.0.1 >> %TMP%\NULL
DEL %TMP%\NULL

Edited by JohnnyJammer, 10 October 2016 - 06:25 PM.


#4 Joeykong

Joeykong
  • Topic Starter

  • Members
  • 24 posts
  • OFFLINE
  •  
  • Local time:07:39 AM

Posted 18 October 2016 - 10:37 AM

thank you jonny a few questions /issues 

1st this is much quicker now i copied the system info part and made a test with just that it runs quick problems with that is if ran more the once (even if i delete the txt file it makes it puts the info in there over and over again like it shows host name os version ect multiple times another thing is i currently just need it to get the ip not the dns and stuff not like the dns and things (i can probably fix that part my self ) next thing is we have some pc set to static so id like it to get the ip whether its static or DHCP and lastly id like the ping to go to google for 60 seconds and export the results to the txt file with the other info

 

now as for all the other parts im not sure if this is ment to be all 1 script or multiple scripts ?

id also still like it to make a task to run ccleaner 

 

 

thank you in advanced for your help



#5 Joeykong

Joeykong
  • Topic Starter

  • Members
  • 24 posts
  • OFFLINE
  •  
  • Local time:07:39 AM

Posted 18 October 2016 - 12:46 PM

so iv been playing around figured out this is intended to be 1 script i added a few things for it to copy added the ccleaner task setup (had to change the name from clean pc to something else as i was getting a error )

 

i found out why it is getting duplicate info(i will be ruining the script every time i do PM on a pc so i cant have duplicate info ) because every time the part of the script runs to look at that pcstats file it puts the info in there again im trying to make it delete that file at the end of the script and that should fix the issue 

 

another issue im still having is with the IP i want it just to pull the ip if its dhcp or static and be formatted (if possible ) like this xx.xxx.xx.xxx i cant get that to work yet 

i do have it pinging google for 60 seconds and exporting the results so thats good 

 

another thing is with the disk clean up some pc haven't had that run in sometime so is there a way to have that start and have the script continue with out the disk clean up having to be done and hit ok because then i could go to the pc plug in flash drive run the script start AV scans and by the time i update the av the script should be done then wile the AV scan is going the disk clean up can be going because once the script finishes i take the txt file it made and email it to our PM email account so if i have to wait for the disk clean up to be done before i can do that it will take more time so ideally it could be like that starts dose its thing the script finishes i email the txt file then i always tell the end user just let the AV scan run and ill come back and check (i tell them if it says its done and found no infections then close it if it finds stuff call me asap...so i can tell them once the disk clean up is done just hit OK )or if they arent there and the disk clean up was going at the same time as the av scan i could just hit ok when i came back and checked (i could also i guess make that part run at the very end or make a send script just for that if i needed to )

 

 

so basically my issues are getting the IP and having it in the right format 

having the disk clean up not need to be finished for the script to keep going /finish ect

deleting the pcstats txt file so i dont get duplicate info 

 

here is the script now with the changes i made and things i added 

 

 

 

 

@echo off
::Check if 32 or 64-bit OS (Not sure why you even have this here?
copy "links\Driver's Village IT Support.url" "%userprofile%\Desktop"
copy "links\dms2.0.url" "%userprofile%\Desktop"
copy "links\DMS2.0.url" "%userprofile%\Desktop"
copy RunMe.bat c:\PM\
copy WSUSreg.reg c:\PM\
copy cctest.bat c:\PM\
copy reboot.bat c:\PM\
::Reboot PC at 9
Schtasks /create /SC DAILY /TN "autoreboot" /TR "C:/PM/reboot.bat" /ST 21:00"
::run ccleaner at 9am
Schtasks /create /SC DAILY /TN "autocleaner" /TR "C:/PM/cctest.bat" /ST 09:00"
 
::Clean Internet Explorer of all cookies and temp files
RUNDLL32.EXE inetcpl.cpl,ClearMyTracksByProcess 8
 
::Now run Cleanmanager using the verylow disk switch
cleanmgr /verylowdisk
 
:: get syustem information
::Do the Systeminfo command once as its 10 times faster, then read the txt file for info
systeminfo >> %temp%\PCStats.txt
type %temp%\PCStats.txt | find /i "Host Name" >> C:\PM\%COMPUTERNAME%.txt
type %temp%\PCStats.txt | find /i "Domain" >> C:\PM\%COMPUTERNAME%.txt
type %temp%\PCStats.txt | find /i "OS Name" >> C:\PM\%COMPUTERNAME%.txt
type %temp%\PCStats.txt | find /i "OS Version" >> C:\PM\%COMPUTERNAME%.txt
type %temp%\PCStats.txt | find /i "System Manufacturer" >> C:\PM\%COMPUTERNAME%.txt
type %temp%\PCStats.txt | find /i "System Model" >> C:\PM\%COMPUTERNAME%.txt
type %temp%\PCStats.txt | find /i "System type" >> C:\PM\%COMPUTERNAME%.txt
type %temp%\PCStats.txt | find /i "Total Physical Memory" >> C:\PM\%COMPUTERNAME%.txt
type %temp%\PCStats.txt | find /i "IPv4" >> C:\PM\%COMPUTERNAME%.txt
::Now lets use WMIC
wmic diskdrive get size >> C:\PM\%COMPUTERNAME%.txt
wmic bios get serialnumber >> C:\PM\%COMPUTERNAME%.txt
wmic cpu get name>>C:\PM\%COMPUTERNAME%.txt
::Finished
ECHO System Cleanup Complete.......
ECHO Closing in 60 seconds.....
ping -n 60 www.google.com >> C:\PM\%COMPUTERNAME%.txt
DEL %TMP%\NULL
DEL C:\Users\%userprofile%\AppData\Local\Temp\PCStats.txt


#6 JohnnyJammer

JohnnyJammer

  • Members
  • 1,117 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:QLD Australia
  • Local time:04:39 PM

Posted 18 October 2016 - 06:26 PM

Ok done. here are the changes

@echo off
::Delete the 2 files if they exist
IF EXISTS %TMP%\NULL DEL %TMP%\NULL
IF EXISTS %TMP%\PCStats.txt DEL %TMP%\PCStats.txt
::Copy the Files over
copy "links\Driver's Village IT Support.url" "%userprofile%\Desktop"
copy "links\dms2.0.url" "%userprofile%\Desktop"
copy "links\DMS2.0.url" "%userprofile%\Desktop"
copy RunMe.bat c:\PM\
copy WSUSreg.reg c:\PM\
copy cctest.bat c:\PM\
copy reboot.bat c:\PM\
::Reboot PC at 9
Schtasks /create /SC DAILY /TN "autoreboot" /TR "C:/PM/reboot.bat" /ST 21:00"
::run ccleaner at 9am
Schtasks /create /SC DAILY /TN "autocleaner" /TR "C:/PM/cctest.bat" /ST 09:00"
::Clean Internet Explorer of all cookies and temp files
RUNDLL32.EXE inetcpl.cpl,ClearMyTracksByProcess 8
::Now run Cleanmanager using the verylow disk switch
cleanmgr /verylowdisk
:: get syustem information
::Do the Systeminfo command once as its 10 times faster, then read the txt file for info
systeminfo >> %temp%\PCStats.txt
type %temp%\PCStats.txt | find /i "Host Name: " >> C:\PM\%COMPUTERNAME%.txt
type %temp%\PCStats.txt | find /i "Domain: " >> C:\PM\%COMPUTERNAME%.txt
type %temp%\PCStats.txt | find /i "OS Name: " >> C:\PM\%COMPUTERNAME%.txt
type %temp%\PCStats.txt | find /i "OS Version: " >> C:\PM\%COMPUTERNAME%.txt
type %temp%\PCStats.txt | find /i "System Manufacturer: " >> C:\PM\%COMPUTERNAME%.txt
type %temp%\PCStats.txt | find /i "System Model: " >> C:\PM\%COMPUTERNAME%.txt
type %temp%\PCStats.txt | find /i "System type: " >> C:\PM\%COMPUTERNAME%.txt
type %temp%\PCStats.txt | find /i "Total Physical Memory: " >> C:\PM\%COMPUTERNAME%.txt
::Now lets use WMIC
wmic diskdrive get size >> C:\PM\%COMPUTERNAME%.txt
wmic bios get serialnumber >> C:\PM\%COMPUTERNAME%.txt
wmic cpu get name >> C:\PM\%COMPUTERNAME%.txt
wmic nicconfig where ipenabled="true" get ipaddress >> "IPv4: " >> C:\PM\%COMPUTERNAME%.txt
::Finished
ECHO System Cleanup Complete.......
ECHO Closing in 60 seconds.....
ping -n 60 www.google.com >> C:\PM\%COMPUTERNAME%_Ping.txt
exit

 

Still not sure why you have the seperate bacth files below mate when it can all be done in the one batch.

copy RunMe.bat c:\PM\ ((What does this do, call the original batch file))
copy WSUSreg.reg c:\PM\ ((This should be done through group policy)
copy cctest.bat c:\PM\   ((I guess this is for ccleaner, its better to use the cleanmgr.exe inbuilt in windows))
copy reboot.bat c:\PM\  ((IS this to create a reboot ata  time because you can use the Run At commmand)


#7 Joeykong

Joeykong
  • Topic Starter

  • Members
  • 24 posts
  • OFFLINE
  •  
  • Local time:07:39 AM

Posted 19 October 2016 - 12:59 PM

when i run the new one the cmd flashes real quick then goes away and nothing pops up 

 

run me and the wsus reg were not made by me they the company who manage our WSUS server for windows updates not sure why they needed a bat for that as you an just double click the reg file and it will add it /make the changes to the registry 

 

the cctest is a script that just runs ccleaner when doing pm i just run that script manually also 

and the reboot one just reboots the pc 

 

 

now im thinking ill have one script called copy scripts and that will copy the run me,wsus.cctest,reboot and the script we are working on to the c:\PM folder 

the reason being is currently if i plug the flash drive in and run our script i gotta leave it in the whole time it is running (now the longest its taken so far on the handful of pc iv tested on is 2 min)other wise it dosnt seem to delete the temp and other things (i honestly forgot exactly what it skips but it dose skip some things )but if i can have it copied to the C drive then i can pop the flash drive in run the copy script pop it out plug it into the next pc wile it takes the 30 sec for it to recognize the flash drive i can look back at the 1st pc go to the c drive start our script start malwarebytes update wile thats loading go to pc 2 run the copy script and repeat .....now i can make the copy scrip my self (and i did make it lol )but for some reason when it tries to copy the bleeping script2.bat(thats what i named our script ) it says the system cannot find the file specified ... im sure i can figure that part out my self 

 

 

now since i wrote you last iv added more to the script (made it delete my old clean pc task..because when upgrading from windows 7 to 10 it messed that up on some pc's and wont let me re add it i just get a error but if i ad the new one called auto cleaner(same script and task just changed the name lol ) it works i also got the IP part to work by using the part from my original script 

and i got it to delete the temp and pcstats file at the end and i also got it set so right before it starts the system info it deletes the old txt file in the PM folder from last time i ran it 

(i will post my current version of our script at the end )

 

so now the issue is the last one you posted seems to open for just a split second then goes away and because of that im obviously un able to see any tweaks or changes you made so once you fix that we can go from there and THANK YOU again for your help our script once we get it all tweaked and working is gonna make my life and co workers lives a lot easier and is much better and way faster then my original script 

 

 

 

here is my current version of our script 

 

 

@echo off
::Check if 32 or 64-bit OS (Not sure why you even have this here?
copy "links\Driver's Village IT Support.url" "%userprofile%\Desktop"
copy "links\dms2.0.url" "%userprofile%\Desktop"
copy "links\DMS2.0.url" "%userprofile%\Desktop"
copy RunMe.bat c:\PM\
copy WSUSreg.reg c:\PM\
copy cctest.bat c:\PM\
copy reboot.bat c:\PM\
::Reboot PC at 9
Schtasks /create /SC DAILY /TN "autoreboot" /TR "C:/PM/reboot.bat" /ST 21:00"
::run ccleaner at 9am
Schtasks /create /SC DAILY /TN "autocleaner" /TR "C:/PM/cctest.bat" /ST 09:00"
::remove old task
Schtasks /Delete /TN "cleanpc"
 
::Clean Internet Explorer of all cookies and temp files
RUNDLL32.EXE inetcpl.cpl,ClearMyTracksByProcess 8
 
::Now run Cleanmanager using the verylow disk switch
cleanmgr /verylowdisk
 
:: get syustem information
::Do the Systeminfo command once as its 10 times faster, then read the txt file for info
: cleaer txt from last time 
del C:\PM\%COMPUTERNAME%.txt
systeminfo >> %temp%\PCStats.txt
type %temp%\PCStats.txt | find /i "Host Name" >> C:\PM\%COMPUTERNAME%.txt
type %temp%\PCStats.txt | find /i "Domain" >> C:\PM\%COMPUTERNAME%.txt
type %temp%\PCStats.txt | find /i "OS Name" >> C:\PM\%COMPUTERNAME%.txt
type %temp%\PCStats.txt | find /i "OS Version" >> C:\PM\%COMPUTERNAME%.txt
type %temp%\PCStats.txt | find /i "System Manufacturer" >> C:\PM\%COMPUTERNAME%.txt
type %temp%\PCStats.txt | find /i "System Model" >> C:\PM\%COMPUTERNAME%.txt
type %temp%\PCStats.txt | find /i "System type" >> C:\PM\%COMPUTERNAME%.txt
type %temp%\PCStats.txt | find /i "Total Physical Memory" >> C:\PM\%COMPUTERNAME%.txt
ipconfig | findstr IPv4>>C:\PM\%COMPUTERNAME%.txt
::Now lets use WMIC
wmic diskdrive get size >> C:\PM\%COMPUTERNAME%.txt
wmic bios get serialnumber >> C:\PM\%COMPUTERNAME%.txt
wmic cpu get name>>C:\PM\%COMPUTERNAME%.txt
::Finished
ECHO System Cleanup Complete.......
ECHO Closing in 60 seconds.....
ping -n 60 www.google.com >> C:\PM\%COMPUTERNAME%.txt
DEL %TMP%\NULL
del %TEMP%\*.* /f /s /q


#8 JohnnyJammer

JohnnyJammer

  • Members
  • 1,117 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:QLD Australia
  • Local time:04:39 PM

Posted 19 October 2016 - 05:42 PM

Ok sorry, since you are not using >> ping to NULL we dont need that, we can change the script like so.

Also i stuffed this line up

wmic nicconfig where ipenabled="true" get ipaddress >> "IPv4: " >> C:\PM\%COMPUTERNAME%.txt

to

wmic nicconfig where ipenabled="true" get ipaddress >> C:\PM\%COMPUTERNAME%.txt

 

the rest should work mate, so the final should be

.

Things to note are:

You dont need ccleaner when you use cleanmgr /verylowdisk and you are also using the del %TMP%\*.* at the end of the script + the (RUNDLL32.EXE inetcpl.cpl,ClearMyTracksByProcess 8) command which cleans all cookies etc so this is basically what ccleaner is going to do anyway.

Like i said with WSUS, this should never be done through registry because if your WSUS server dies, its quicker and faster to change the host name in the WSUS GPO (Also strucutr your WSUS server exactly like your active directory OU groups).

Also another good practice is to always check if an object exists like so

IF NOT EXIST ("%userprofile%\Desktop\Driver's Village IT Support.url") DO (copy "links\Driver's Village IT Support.url" "%userprofile%\Desktop")

So if it does exist it simply moves to the next command.

 

This here (Schtasks /Delete /TN "cleanpc") seems to do nothing at all)

@echo off
::Check if 32 or 64-bit OS (Not sure why you even have this here?
copy "links\Driver's Village IT Support.url" "%userprofile%\Desktop"
copy "links\dms2.0.url" "%userprofile%\Desktop"
copy "links\DMS2.0.url" "%userprofile%\Desktop"
copy RunMe.bat c:\PM\
copy WSUSreg.reg c:\PM\
copy cctest.bat c:\PM\
copy reboot.bat c:\PM\
::Reboot PC at 9
Schtasks /create /SC DAILY /TN "autoreboot" /TR "C:/PM/reboot.bat" /ST 21:00"
::run ccleaner at 9am
Schtasks /create /SC DAILY /TN "autocleaner" /TR "C:/PM/cctest.bat" /ST 09:00"
::remove old task
Schtasks /Delete /TN "cleanpc"
 
::Clean Internet Explorer of all cookies and temp files
RUNDLL32.EXE inetcpl.cpl,ClearMyTracksByProcess 8
 
::Now run Cleanmanager using the verylow disk switch
cleanmgr /verylowdisk
 
:: get syustem information
::Do the Systeminfo command once as its 10 times faster, then read the txt file for info
: cleaer txt from last time
del C:\PM\%COMPUTERNAME%.txt
systeminfo >> %temp%\PCStats.txt
type %temp%\PCStats.txt | find /i "Host Name" >> C:\PM\%COMPUTERNAME%.txt
type %temp%\PCStats.txt | find /i "Domain" >> C:\PM\%COMPUTERNAME%.txt
type %temp%\PCStats.txt | find /i "OS Name" >> C:\PM\%COMPUTERNAME%.txt
type %temp%\PCStats.txt | find /i "OS Version" >> C:\PM\%COMPUTERNAME%.txt
type %temp%\PCStats.txt | find /i "System Manufacturer" >> C:\PM\%COMPUTERNAME%.txt
type %temp%\PCStats.txt | find /i "System Model" >> C:\PM\%COMPUTERNAME%.txt
type %temp%\PCStats.txt | find /i "System type" >> C:\PM\%COMPUTERNAME%.txt
type %temp%\PCStats.txt | find /i "Total Physical Memory" >> C:\PM\%COMPUTERNAME%.txt
::Now lets use WMIC
wmic diskdrive get size >> C:\PM\%COMPUTERNAME%.txt
wmic bios get serialnumber >> C:\PM\%COMPUTERNAME%.txt
wmic cpu get name>>C:\PM\%COMPUTERNAME%.txt
wmic nicconfig where ipenabled="true" get ipaddress >> C:\PM\%COMPUTERNAME%.txt
::Finished
ECHO System Cleanup Complete.......
ECHO Closing in 60 seconds.....
ping -n 60 www.google.com >> C:\PM\%COMPUTERNAME%.txt
del %TEMP%\*.* /f /s /q

Edited by JohnnyJammer, 19 October 2016 - 05:57 PM.


#9 Joeykong

Joeykong
  • Topic Starter

  • Members
  • 24 posts
  • OFFLINE
  •  
  • Local time:07:39 AM

Posted 24 October 2016 - 12:34 PM

i ended up with this 

using this to copy everything this way i can pop the flash drive in run that pop it out and then run our script off the C drive this way i can put the flash drive in the next pc 

@echo off
::Check if 32 or 64-bit OS (Not sure why you even have this here?
copy "links\Driver's Village IT Support.url" "%userprofile%\Desktop"
copy "links\dms2.0.url" "%userprofile%\Desktop"
copy "links\DMS2.0.url" "%userprofile%\Desktop"
copy RunMe.bat c:\PM\
copy WSUSreg.reg c:\PM\
copy cctest.bat c:\PM\
copy reboot.bat c:\PM\
copy bleepingscript2.bat c:\PM\
 
pause

 

 

 

then our script i got this and it works perfect 

 

@echo off
::Reboot PC at 9
Schtasks /create /SC DAILY /TN "autoreboot" /TR "C:/PM/reboot.bat" /ST 21:00"
::run ccleaner at 9am
Schtasks /create /SC DAILY /TN "autocleaner" /TR "C:/PM/cctest.bat" /ST 09:00"
::remove old task
Schtasks /Delete /TN "cleanpc"
 
::Clean Internet Explorer of all cookies and temp files
RUNDLL32.EXE inetcpl.cpl,ClearMyTracksByProcess 8
 
::Now run Cleanmanager using the verylow disk switch
cleanmgr /verylowdisk
 
:: get syustem information
::Do the Systeminfo command once as its 10 times faster, then read the txt file for info
: cleaer txt from last time 
del C:\PM\%COMPUTERNAME%.txt
systeminfo >> %temp%\PCStats.txt
type %temp%\PCStats.txt | find /i "Host Name" >> C:\PM\%COMPUTERNAME%.txt
type %temp%\PCStats.txt | find /i "Domain" >> C:\PM\%COMPUTERNAME%.txt
type %temp%\PCStats.txt | find /i "OS Name" >> C:\PM\%COMPUTERNAME%.txt
type %temp%\PCStats.txt | find /i "OS Version" >> C:\PM\%COMPUTERNAME%.txt
type %temp%\PCStats.txt | find /i "System Manufacturer" >> C:\PM\%COMPUTERNAME%.txt
type %temp%\PCStats.txt | find /i "System Model" >> C:\PM\%COMPUTERNAME%.txt
type %temp%\PCStats.txt | find /i "System type" >> C:\PM\%COMPUTERNAME%.txt
type %temp%\PCStats.txt | find /i "Total Physical Memory" >> C:\PM\%COMPUTERNAME%.txt
ipconfig | findstr IPv4>>C:\PM\%COMPUTERNAME%.txt
::Now lets use WMIC
wmic diskdrive get size >> C:\PM\%COMPUTERNAME%.txt
wmic bios get serialnumber >> C:\PM\%COMPUTERNAME%.txt
wmic cpu get name>>C:\PM\%COMPUTERNAME%.txt
::Finished
ECHO System Cleanup Complete.......
ECHO Closing in 60 seconds.....
ping -n 60 www.google.com >> C:\PM\%COMPUTERNAME%.txt
DEL %TMP%\NULL
del %TEMP%\*.* /f /s /q
 
 
 
thank you very much for your help 


#10 Joeykong

Joeykong
  • Topic Starter

  • Members
  • 24 posts
  • OFFLINE
  •  
  • Local time:07:39 AM

Posted 25 October 2016 - 12:24 PM

i might do a youtube video showing this script if so i will be sure to give you credit for helping me :D






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users