This morning received the telephone, said that need a change DNS for school DNS, and empty IE temporary files script, don't want to, with batch write a:
Copy Code code as follows:
REM programed by Kaisir
@echo off
The function of the echo script is to modify your DNS for the Shandong Youth Political college dedicated DNS 222.194.76.2 also helps you clean up temporary files on your computer. If you have any questions, please call the Network Center.
Pause
echo Modifies DNS ...
netsh interface ip set DNS "Local Area Connection" Source=static addr=222.194.76.2
Echo DNS has been successfully modified and will then begin emptying ie temporary files ...
Pause
echo Clears temporary file ...
del/f/s/q "%userprofile%local settingstemporary Internet files*.*"
del/f/s/q "%userprofile%appdatalocalmicrosoftwindowstemporary Internet files*.*"
Echo full operation completed successfully! Thank you for your use.
Pause
You see, the idea is very simple, with Netsh to change the DNS is, because to adapt to Win7 and XP temporary directory, so the deletion of the statement wrote two times.
But, to think about it, this script has a lot of problems,
1 if the user has more than one network card, this script will only modify the "local connection" that.
2 If the user has manually modified the location of the temporary file, then this script can not be powerless.
So, here's the script for the VBS version.
Copy Code code as follows:
' Delete all files and folders under the directory
Const deletereadonly = True
Set objFSO = CreateObject ("Scripting.FileSystemObject")
objFSO.DeleteFile (net_temp& "*.*"), deletereadonly
StrComputer = "."
Set objWMIService = GetObject ("winmgmts:" & StrComputer & "Rootcimv2")
Set ColSubfolders2 = objWMIService.ExecQuery _
("Associators of {win32_directory.name= '" & Net_temp & "}" _
& "Where AssocClass = win32_subdirectory" _
& "Resultrole = PartComponent")
For each objFolder2 in ColSubfolders2
Objfso.deletefolder Objfolder2.name, Deletereadonly
Next
MsgBox ("All operations executed successfully!")
Else
End If
This is more intelligent, through the winmgmts to get a list of network cards in the system, and then traverse the enabled network card, and then modify. The Temporary Files section is also used to get the folder location by reading the key value of the registry "Hkcusoftwaremicrosoftwindowscurrentversionexplorershell Folderscache" entry. And then kill him by the corresponding method of the FSO object created