Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to implement the functions of modifying DNS and emptying temporary IE files with vbs script

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly introduces how to modify DNS and clear IE temporary file function of vbs script, which has certain reference value. Interested friends can refer to it. I hope you will gain a lot after reading this article. Let Xiaobian take you to understand it together.

Need a modify DNS for the school DNS, and empty IE temporary file script, want not to think, with batch processing to write a:

rem programmed by Kaisir@echo offecho This script changes your DNS to 222.194.76.2 and clears temporary files from your computer. If you have any questions, please call the Network Centre. pauseecho Modify DNS in... netsh interface ip set dns "local connection" source=static addr=222.194.76.2echo DNS has been modified successfully, next will start to empty ie temporary file... pauseecho Clear temporary files... del /f /s /q "%userprofile%Local SettingsTemporary Internet Files*.* "del /f /s /q "%userprofile%AppDataLocalMicrosoftWindowsTemporary Internet Files*.* "echo All operations completed successfully! Thank you for using it. pause

You see, the idea is very simple, use netsh to change the dns is, because to adapt to Win7 and Xp temporary directory is different, so delete the statement written twice.

But, on second thought, this script has a lot of problems,

1) If the user has multiple network cards, this script will only modify the "local connection" one.

2) If the user manually modifies the location of the temporary file himself, this script will not do anything.

So here's the vbs script.

'Delete all files and folders in 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! ")elseend if

This is more intelligent, through winmgmts to obtain the network card list in the system, and then traverse the enabled network card, and then modify. The temporary file section also obtains the folder location by reading the key value of the registry "HKCU software Microsoft Windows Current Version Explorer Shell Folderscache" entry. Then kill him by creating the corresponding method of the fso object ~

Thank you for reading this article carefully. I hope that the article "How to modify DNS and clear IE temporary files by vbs script" shared by Xiaobian will be helpful to everyone. At the same time, I hope that everyone will support you a lot and pay attention to the industry information channel. More relevant knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report