IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> Python知识库 -> python使用pyqt5制作exe电脑小工具 -> 正文阅读

[Python知识库]python使用pyqt5制作exe电脑小工具

?call_cxtool.py 用来调用界面的开始界面

# -*- coding: utf-8 -*-# Form implementation generated from reading ui file 'connect_me.ui'#

# Created by: PyQt5 UI code generator 5.11.3#
# WARNING! All changes made in this file will be lost!#导入程序运行必须模块
# PyQt5中使用的基本控件都在PyQt5.QtWidgets模块中
import sys
from PyQt5.QtWidgets import QApplication, QMainWindow  # #导入designer工具生成的login模块
from cxtool import Ui_ToolMainWindow


class MyMainForm(QMainWindow, Ui_ToolMainWindow):
    def __init__(self, parent=None):
        super(MyMainForm, self).__init__(parent)
        self.setupUi(self)


if __name__ == "__main__":
    # 固定的,PyQt5程序都需要QApplication对象。sys.argv是命令行参数列表,确保程序可以双击运行
    app = QApplication(sys.argv)
    # 初始化
    myWin = MyMainForm()
    # 将窗口控件显示在屏幕上
    myWin.show()
    # 程序运行,sys.exit方法确保程序完整退出。
    sys.exit(app.exec_())

tool.ui是通过pt designer生成的ui界面,通过PyUIc转化为tool.py (转化方法后续放)

cxtool.py

# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'cxtool.ui'
#
# Created by: PyQt5 UI code generator 5.15.4
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again.  Do not edit this file unless you know what you are doing.

import json
import os
import sys
from configparser import ConfigParser
from shutil import copyfile

import psutil
import win32api
import wmi
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtWidgets import QMessageBox

import func_impl
import function_impl

cp = ConfigParser()
cp.read('config.cfg')
current_working_dir = os.getcwd()
cp.set("database", "root_path", current_working_dir)  # 使用set直接修改指定字段值
with open("config.cfg", "w+") as f:
    cp.write(f)
root_path = cp.get('database', 'root_path')


class Ui_ToolMainWindow(object):
    def setupUi(self, ToolMainWindow):
        ToolMainWindow.setObjectName("ToolMainWindow")
        ToolMainWindow.resize(781, 619)
        self.centralwidget = QtWidgets.QWidget(ToolMainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.tabWidget = QtWidgets.QTabWidget(self.centralwidget)
        self.tabWidget.setGeometry(QtCore.QRect(0, 0, 791, 691))
        self.tabWidget.setLayoutDirection(QtCore.Qt.LeftToRight)
        self.tabWidget.setStyleSheet("*{\n"
                                     "    font: 75 11pt \"微软雅黑\";\n"
                                     "font-weight: bold;\n"
                                     "color:yellow;\n"
                                     "}\n"
                                     "")
        self.tabWidget.setIconSize(QtCore.QSize(88, 28))
        self.tabWidget.setObjectName("tabWidget")
        self.tab_1 = QtWidgets.QWidget()
        self.tab_1.setObjectName("tab_1")
        self.checkBox_ie_set = QtWidgets.QCheckBox(self.tab_1)
        self.checkBox_ie_set.setGeometry(QtCore.QRect(110, 60, 131, 19))
        self.checkBox_ie_set.setCheckable(True)
        self.checkBox_ie_set.setObjectName("checkBox_ie_set")
        self.checkBox_host_domain_map = QtWidgets.QCheckBox(self.tab_1)
        self.checkBox_host_domain_map.setGeometry(QtCore.QRect(450, 60, 181, 19))
        self.checkBox_host_domain_map.setObjectName("checkBox_host_domain_map")
        self.checkBox_c_clear = QtWidgets.QCheckBox(self.tab_1)
        self.checkBox_c_clear.setGeometry(QtCore.QRect(300, 60, 131, 19))
        self.checkBox_c_clear.setObjectName("checkBox_c_clear")
        self.checkBox_restart_print_service = QtWidgets.QCheckBox(self.tab_1)
        self.checkBox_restart_print_service.setGeometry(QtCore.QRect(300, 100, 131, 19))
        self.checkBox_restart_print_service.setObjectName("checkBox_restart_print_service")
        self.checkBox_clear_all_tasks = QtWidgets.QCheckBox(self.tab_1)
        self.checkBox_clear_all_tasks.setGeometry(QtCore.QRect(110, 100, 171, 19))
        self.checkBox_clear_all_tasks.setObjectName("checkBox_clear_all_tasks")
        self.checkBox_fix_dns = QtWidgets.QCheckBox(self.tab_1)
        self.checkBox_fix_dns.setGeometry(QtCore.QRect(110, 140, 151, 19))
        self.checkBox_fix_dns.setObjectName("checkBox_fix_dns")
        self.checkBox_update_AD_domain_strategy = QtWidgets.QCheckBox(self.tab_1)
        self.checkBox_update_AD_domain_strategy.setGeometry(QtCore.QRect(300, 140, 151, 19))
        self.checkBox_update_AD_domain_strategy.setObjectName("checkBox_update_AD_domain_strategy")
        self.line = QtWidgets.QFrame(self.tab_1)
        self.line.setGeometry(QtCore.QRect(310, 20, 341, 31))
        self.line.setFrameShape(QtWidgets.QFrame.HLine)
        self.line.setFrameShadow(QtWidgets.QFrame.Sunken)
        self.line.setObjectName("line")
        self.line_2 = QtWidgets.QFrame(self.tab_1)
        self.line_2.setGeometry(QtCore.QRect(70, 50, 20, 121))
        self.line_2.setFrameShape(QtWidgets.QFrame.VLine)
        self.line_2.setFrameShadow(QtWidgets.QFrame.Sunken)
        self.line_2.setObjectName("line_2")
        self.line_3 = QtWidgets.QFrame(self.tab_1)
        self.line_3.setGeometry(QtCore.QRect(660, 50, 20, 121))
        self.line_3.setFrameShape(QtWidgets.QFrame.VLine)
        self.line_3.setFrameShadow(QtWidgets.QFrame.Sunken)
        self.line_3.setObjectName("line_3")
        self.line_4 = QtWidgets.QFrame(self.tab_1)
        self.line_4.setGeometry(QtCore.QRect(90, 160, 561, 31))
        self.line_4.setFrameShape(QtWidgets.QFrame.HLine)
        self.line_4.setFrameShadow(QtWidgets.QFrame.Sunken)
        self.line_4.setObjectName("line_4")
        self.label_proxy_ip_address = QtWidgets.QLabel(self.tab_1)
        self.label_proxy_ip_address.setGeometry(QtCore.QRect(90, 210, 111, 21))
        self.label_proxy_ip_address.setObjectName("label_proxy_ip_address")
        self.lineEdit_proxy_ip_address = QtWidgets.QLineEdit(self.tab_1)
        self.lineEdit_proxy_ip_address.setGeometry(QtCore.QRect(210, 210, 151, 31))
        self.lineEdit_proxy_ip_address.setStyleSheet("*{font: 12pt \"阿里巴巴普惠体 R\";\n"
                                                     "font-weight: bold;\n"
                                                     "color:blue;}")
        self.lineEdit_proxy_ip_address.setObjectName("lineEdit_proxy_ip_address")
        self.label_proxy_port = QtWidgets.QLabel(self.tab_1)
        self.label_proxy_port.setGeometry(QtCore.QRect(100, 260, 111, 21))
        self.label_proxy_port.setObjectName("label_proxy_port")
        self.lineEdit_proxy_port = QtWidgets.QLineEdit(self.tab_1)
        self.lineEdit_proxy_port.setGeometry(QtCore.QRect(210, 260, 111, 31))
        self.lineEdit_proxy_port.setStyleSheet("*{font: 12pt \"阿里巴巴普惠体 R\";\n"
                                               "font-weight: bold;\n"
                                               "color:blue;}")
        self.lineEdit_proxy_port.setObjectName("lineEdit_proxy_port")
        self.lineEdit_dns_1 = QtWidgets.QLineEdit(self.tab_1)
        self.lineEdit_dns_1.setGeometry(QtCore.QRect(560, 310, 181, 31))
        self.lineEdit_dns_1.setStyleSheet("*{font: 12pt \"阿里巴巴普惠体 R\";\n"
                                          "font-weight: bold;\n"
                                          "color:blue;}")
        self.lineEdit_dns_1.setObjectName("lineEdit_dns_1")
        self.label_dns_4 = QtWidgets.QLabel(self.tab_1)
        self.label_dns_4.setGeometry(QtCore.QRect(460, 310, 111, 21))
        self.label_dns_4.setObjectName("label_dns_4")
        self.lineEdit_default_gateway = QtWidgets.QLineEdit(self.tab_1)
        self.lineEdit_default_gateway.setGeometry(QtCore.QRect(560, 270, 181, 31))
        self.lineEdit_default_gateway.setStyleSheet("*{font: 12pt \"阿里巴巴普惠体 R\";\n"
                                                    "font-weight: bold;\n"
                                                    "color:blue;}")
        self.lineEdit_default_gateway.setObjectName("lineEdit_default_gateway")
        self.label_default_gateway = QtWidgets.QLabel(self.tab_1)
        self.label_default_gateway.setGeometry(QtCore.QRect(460, 270, 111, 21))
        self.label_default_gateway.setObjectName("label_default_gateway")
        self.lineEdit_subnet_mask = QtWidgets.QLineEdit(self.tab_1)
        self.lineEdit_subnet_mask.setGeometry(QtCore.QRect(560, 230, 181, 31))
        self.lineEdit_subnet_mask.setStyleSheet("*{font: 12pt \"阿里巴巴普惠体 R\";\n"
                                                "font-weight: bold;\n"
                                                "color:blue;}")
        self.lineEdit_subnet_mask.setObjectName("lineEdit_subnet_mask")
        self.label_subnet_mask_2 = QtWidgets.QLabel(self.tab_1)
        self.label_subnet_mask_2.setGeometry(QtCore.QRect(460, 230, 111, 21))
        self.label_subnet_mask_2.setObjectName("label_subnet_mask_2")
        self.lineEdit_ip_address = QtWidgets.QLineEdit(self.tab_1)
        self.lineEdit_ip_address.setGeometry(QtCore.QRect(560, 190, 181, 31))
        self.lineEdit_ip_address.setStyleSheet("*{font: 12pt \"阿里巴巴普惠体 R\";\n"
                                               "font-weight: bold;\n"
                                               "color:blue;}")
        self.lineEdit_ip_address.setText("")
        self.lineEdit_ip_address.setObjectName("lineEdit_ip_address")
        self.label_ip_address = QtWidgets.QLabel(self.tab_1)
        self.label_ip_address.setGeometry(QtCore.QRect(480, 190, 111, 21))
        self.label_ip_address.setStyleSheet("")
        self.label_ip_address.setObjectName("label_ip_address")
        self.lineEdit_dns_2 = QtWidgets.QLineEdit(self.tab_1)
        self.lineEdit_dns_2.setGeometry(QtCore.QRect(560, 350, 181, 31))
        self.lineEdit_dns_2.setStyleSheet("*{font: 12pt \"阿里巴巴普惠体 R\";\n"
                                          "font-weight: bold;\n"
                                          "color:blue;}")
        self.lineEdit_dns_2.setObjectName("lineEdit_dns_2")
        self.label_dns_3 = QtWidgets.QLabel(self.tab_1)
        self.label_dns_3.setGeometry(QtCore.QRect(460, 350, 111, 21))
        self.label_dns_3.setObjectName("label_dns_3")
        self.pushButton_software_download = QtWidgets.QPushButton(self.tab_1)
        self.pushButton_software_download.setGeometry(QtCore.QRect(120, 410, 181, 81))
        self.pushButton_software_download.setStyleSheet("*{\n"
                                                        "font: 12pt \"阿里巴巴普惠体 R\";\n"
                                                        "font-weight: bold;\n"
                                                        "color:blue;\n"
                                                        "}\n"
                                                        "")
        self.pushButton_software_download.setObjectName("pushButton_software_download")
        self.pushButton_onepush = QtWidgets.QPushButton(self.tab_1)
        self.pushButton_onepush.setGeometry(QtCore.QRect(460, 410, 181, 81))
        self.pushButton_onepush.setStyleSheet("*{\n"
                                              "font: 15pt \"阿里巴巴普惠体 R\";\n"
                                              "font-weight: bold;\n"
                                              "color:blue;\n"
                                              "}\n"
                                              "")
        self.pushButton_onepush.setObjectName("pushButton_onepush")
        self.label_version_1 = QtWidgets.QLabel(self.tab_1)
        self.label_version_1.setGeometry(QtCore.QRect(20, 530, 161, 16))
        self.label_version_1.setStyleSheet("*{\n"
                                           "    font: 75 10pt \"微软雅黑\";\n"
                                           "font-weight: bold;\n"
                                           "color:white;\n"
                                           "}")
        self.label_version_1.setObjectName("label_version_1")
        self.line_9 = QtWidgets.QFrame(self.tab_1)
        self.line_9.setGeometry(QtCore.QRect(80, 190, 291, 16))
        self.line_9.setFrameShape(QtWidgets.QFrame.HLine)
        self.line_9.setFrameShadow(QtWidgets.QFrame.Sunken)
        self.line_9.setObjectName("line_9")
        self.line_10 = QtWidgets.QFrame(self.tab_1)
        self.line_10.setGeometry(QtCore.QRect(70, 210, 16, 141))
        self.line_10.setFrameShape(QtWidgets.QFrame.VLine)
        self.line_10.setFrameShadow(QtWidgets.QFrame.Sunken)
        self.line_10.setObjectName("line_10")
        self.line_11 = QtWidgets.QFrame(self.tab_1)
        self.line_11.setGeometry(QtCore.QRect(80, 360, 291, 16))
        self.line_11.setFrameShape(QtWidgets.QFrame.HLine)
        self.line_11.setFrameShadow(QtWidgets.QFrame.Sunken)
        self.line_11.setObjectName("line_11")
        self.line_12 = QtWidgets.QFrame(self.tab_1)
        self.line_12.setGeometry(QtCore.QRect(370, 210, 16, 141))
        self.line_12.setFrameShape(QtWidgets.QFrame.VLine)
        self.line_12.setFrameShadow(QtWidgets.QFrame.Sunken)
        self.line_12.setObjectName("line_12")
        self.groupBox = QtWidgets.QGroupBox(self.tab_1)
        self.groupBox.setGeometry(QtCore.QRect(190, 310, 141, 51))
        self.groupBox.setStyleSheet("*{\n"
                                    "font: 75 9pt \"微软雅黑\";\n"
                                    "color:white\n"
                                    "}")
        self.groupBox.setTitle("")
        self.groupBox.setObjectName("groupBox")
        self.radioButton_switch_off = QtWidgets.QRadioButton(self.groupBox)
        self.radioButton_switch_off.setGeometry(QtCore.QRect(80, 20, 51, 19))
        self.radioButton_switch_off.setStyleSheet("*{\n"
                                                  "    font: 75 11pt \"微软雅黑\";\n"
                                                  "font-weight: bold;\n"
                                                  "color:yellow;\n"
                                                  "}")
        self.radioButton_switch_off.setChecked(True)
        self.radioButton_switch_off.setObjectName("radioButton_switch_off")
        self.radioButton_switch_on = QtWidgets.QRadioButton(self.groupBox)
        self.radioButton_switch_on.setGeometry(QtCore.QRect(20, 20, 61, 19))
        self.radioButton_switch_on.setStyleSheet("*{\n"
                                                 "    font: 75 11pt \"微软雅黑\";\n"
                                                 "font-weight: bold;\n"
                                                 "color:yellow;\n"
                                                 "}")
        self.radioButton_switch_on.setChecked(False)
        self.radioButton_switch_on.setObjectName("radioButton_switch_on")
        self.groupBox_2 = QtWidgets.QGroupBox(self.tab_1)
        self.groupBox_2.setGeometry(QtCore.QRect(110, 20, 201, 31))
        self.groupBox_2.setStyleSheet("*{\n"
                                      "\n"
                                      "font: 75 9pt \"微软雅黑\";\n"
                                      "color:white;\n"
                                      "}")
        self.groupBox_2.setTitle("")
        self.groupBox_2.setObjectName("groupBox_2")
        self.radioButton_cancel_all = QtWidgets.QRadioButton(self.groupBox_2)
        self.radioButton_cancel_all.setGeometry(QtCore.QRect(90, 0, 101, 19))
        self.radioButton_cancel_all.setStyleSheet("*{\n"
                                                  "    font: 75 10pt \"微软雅黑\";\n"
                                                  "font-weight: bold;\n"
                                                  "color:yellow;\n"
                                                  "}\n"
                                                  "")
        self.radioButton_cancel_all.setObjectName("radioButton_cancel_all")
        self.radioButton_all = QtWidgets.QRadioButton(self.groupBox_2)
        self.radioButton_all.setGeometry(QtCore.QRect(20, 0, 61, 19))
        self.radioButton_all.setStyleSheet("*{\n"
                                           "    font: 75 10pt \"微软雅黑\";\n"
                                           "font-weight: bold;\n"
                                           "color:yellow;\n"
                                           "}\n"
                                           "")
        self.radioButton_all.setObjectName("radioButton_all")
        self.listView = QtWidgets.QListView(self.tab_1)
        self.listView.setGeometry(QtCore.QRect(-60, -20, 831, 631))
        self.listView.setStyleSheet("background:url(:/picture/light.jpeg)")
        self.listView.setObjectName("listView")
        self.line_5 = QtWidgets.QFrame(self.tab_1)
        self.line_5.setGeometry(QtCore.QRect(0, 510, 771, 16))
        self.line_5.setFrameShape(QtWidgets.QFrame.HLine)
        self.line_5.setFrameShadow(QtWidgets.QFrame.Sunken)
        self.line_5.setObjectName("line_5")
        self.line_7 = QtWidgets.QFrame(self.tab_1)
        self.line_7.setGeometry(QtCore.QRect(90, 30, 21, 20))
        self.line_7.setFrameShape(QtWidgets.QFrame.HLine)
        self.line_7.setFrameShadow(QtWidgets.QFrame.Sunken)
        self.line_7.setObjectName("line_7")
        self.label = QtWidgets.QLabel(self.tab_1)
        self.label.setGeometry(QtCore.QRect(100, 330, 91, 16))
        self.label.setObjectName("label")
        self.line_8 = QtWidgets.QFrame(self.tab_1)
        self.line_8.setGeometry(QtCore.QRect(0, 550, 771, 16))
        self.line_8.setFrameShape(QtWidgets.QFrame.HLine)
        self.line_8.setFrameShadow(QtWidgets.QFrame.Sunken)
        self.line_8.setObjectName("line_8")
        self.line_16 = QtWidgets.QFrame(self.tab_1)
        self.line_16.setGeometry(QtCore.QRect(160, 520, 20, 41))
        self.line_16.setFrameShape(QtWidgets.QFrame.VLine)
        self.line_16.setFrameShadow(QtWidgets.QFrame.Sunken)
        self.line_16.setObjectName("line_16")
        self.line_17 = QtWidgets.QFrame(self.tab_1)
        self.line_17.setGeometry(QtCore.QRect(0, 520, 20, 41))
        self.line_17.setFrameShape(QtWidgets.QFrame.VLine)
        self.line_17.setFrameShadow(QtWidgets.QFrame.Sunken)
        self.line_17.setObjectName("line_17")
        self.listView.raise_()
        self.checkBox_ie_set.raise_()
        self.checkBox_host_domain_map.raise_()
        self.checkBox_c_clear.raise_()
        self.checkBox_restart_print_service.raise_()
        self.checkBox_clear_all_tasks.raise_()
        self.checkBox_fix_dns.raise_()
        self.checkBox_update_AD_domain_strategy.raise_()
        self.line.raise_()
        self.line_2.raise_()
        self.line_3.raise_()
        self.line_4.raise_()
        self.label_proxy_ip_address.raise_()
        self.lineEdit_proxy_ip_address.raise_()
        self.label_proxy_port.raise_()
        self.lineEdit_proxy_port.raise_()
        self.lineEdit_dns_1.raise_()
        self.label_dns_4.raise_()
        self.lineEdit_default_gateway.raise_()
        self.label_default_gateway.raise_()
        self.lineEdit_subnet_mask.raise_()
        self.label_subnet_mask_2.raise_()
        self.lineEdit_ip_address.raise_()
        self.label_ip_address.raise_()
        self.lineEdit_dns_2.raise_()
        self.label_dns_3.raise_()
        self.pushButton_software_download.raise_()
        self.pushButton_onepush.raise_()
        self.label_version_1.raise_()
        self.line_9.raise_()
        self.line_10.raise_()
        self.line_11.raise_()
        self.line_12.raise_()
        self.groupBox.raise_()
        self.groupBox_2.raise_()
        self.line_5.raise_()
        self.line_7.raise_()
        self.label.raise_()
        self.line_8.raise_()
        self.line_16.raise_()
        self.line_17.raise_()
        icon = QtGui.QIcon()
        icon.addPixmap(QtGui.QPixmap(":/picture/sys.jpg"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.tabWidget.addTab(self.tab_1, icon, "")
        self.tab_2 = QtWidgets.QWidget()
        self.tab_2.setObjectName("tab_2")
        self.label_version = QtWidgets.QLabel(self.tab_2)
        self.label_version.setGeometry(QtCore.QRect(20, 530, 181, 16))
        self.label_version.setStyleSheet("*{\n"
                                         "    font: 75 10pt \"微软雅黑\";\n"
                                         "font-weight: bold;\n"
                                         "color:white;\n"
                                         "}")
        self.label_version.setObjectName("label_version")
        self.label_computerName = QtWidgets.QLabel(self.tab_2)
        self.label_computerName.setGeometry(QtCore.QRect(50, 70, 101, 16))
        self.label_computerName.setObjectName("label_computerName")
        self.line_computerName = QtWidgets.QLineEdit(self.tab_2)
        self.line_computerName.setGeometry(QtCore.QRect(150, 60, 221, 31))
        self.line_computerName.setStyleSheet("*{font: 12pt \"阿里巴巴普惠体 R\";\n"
                                             "font-weight: bold;\n"
                                             "color:blue;}")
        self.line_computerName.setObjectName("line_computerName")
        self.label_p_13 = QtWidgets.QLabel(self.tab_2)
        self.label_p_13.setGeometry(QtCore.QRect(50, 110, 101, 16))
        self.label_p_13.setObjectName("label_p_13")
        self.p_13 = QtWidgets.QLineEdit(self.tab_2)
        self.p_13.setGeometry(QtCore.QRect(150, 100, 221, 31))
        self.p_13.setStyleSheet("*{font: 12pt \"阿里巴巴普惠体 R\";\n"
                                "font-weight: bold;\n"
                                "color:blue;}")
        self.p_13.setObjectName("p_13")
        self.label_ipAdress = QtWidgets.QLabel(self.tab_2)
        self.label_ipAdress.setGeometry(QtCore.QRect(50, 150, 101, 16))
        self.label_ipAdress.setObjectName("label_ipAdress")
        self.line_ipAdress = QtWidgets.QLineEdit(self.tab_2)
        self.line_ipAdress.setGeometry(QtCore.QRect(150, 140, 221, 31))
        self.line_ipAdress.setStyleSheet("*{font: 12pt \"阿里巴巴普惠体 R\";\n"
                                         "font-weight: bold;\n"
                                         "color:blue;}")
        self.line_ipAdress.setObjectName("line_ipAdress")
        self.label_macAddress = QtWidgets.QLabel(self.tab_2)
        self.label_macAddress.setGeometry(QtCore.QRect(50, 190, 101, 16))
        self.label_macAddress.setObjectName("label_macAddress")
        self.macAddress = QtWidgets.QLineEdit(self.tab_2)
        self.macAddress.setGeometry(QtCore.QRect(150, 180, 221, 31))
        self.macAddress.setStyleSheet("*{font: 12pt \"阿里巴巴普惠体 R\";\n"
                                      "font-weight: bold;\n"
                                      "color:blue;}")
        self.macAddress.setObjectName("macAddress")
        self.label_subnet_mask = QtWidgets.QLabel(self.tab_2)
        self.label_subnet_mask.setGeometry(QtCore.QRect(50, 230, 101, 16))
        self.label_subnet_mask.setObjectName("label_subnet_mask")
        self.subnet_mask = QtWidgets.QLineEdit(self.tab_2)
        self.subnet_mask.setGeometry(QtCore.QRect(150, 220, 221, 31))
        self.subnet_mask.setStyleSheet("*{font: 12pt \"阿里巴巴普惠体 R\";\n"
                                       "font-weight: bold;\n"
                                       "color:blue;}")
        self.subnet_mask.setObjectName("subnet_mask")
        self.label_dns_1 = QtWidgets.QLabel(self.tab_2)
        self.label_dns_1.setGeometry(QtCore.QRect(50, 270, 101, 16))
        self.label_dns_1.setObjectName("label_dns_1")
        self.line_dns_1 = QtWidgets.QLineEdit(self.tab_2)
        self.line_dns_1.setGeometry(QtCore.QRect(150, 260, 221, 31))
        self.line_dns_1.setStyleSheet("*{font: 12pt \"阿里巴巴普惠体 R\";\n"
                                      "font-weight: bold;\n"
                                      "color:blue;}")
        self.line_dns_1.setObjectName("line_dns_1")
        self.label_dns_2 = QtWidgets.QLabel(self.tab_2)
        self.label_dns_2.setGeometry(QtCore.QRect(50, 310, 101, 16))
        self.label_dns_2.setObjectName("label_dns_2")
        self.line_dns_2 = QtWidgets.QLineEdit(self.tab_2)
        self.line_dns_2.setGeometry(QtCore.QRect(150, 300, 221, 31))
        self.line_dns_2.setStyleSheet("*{font: 12pt \"阿里巴巴普惠体 R\";\n"
                                      "font-weight: bold;\n"
                                      "color:blue;}")
        self.line_dns_2.setObjectName("line_dns_2")
        self.label_gateway = QtWidgets.QLabel(self.tab_2)
        self.label_gateway.setGeometry(QtCore.QRect(50, 350, 101, 16))
        self.label_gateway.setObjectName("label_gateway")
        self.line_gateway = QtWidgets.QLineEdit(self.tab_2)
        self.line_gateway.setGeometry(QtCore.QRect(150, 340, 221, 31))
        self.line_gateway.setStyleSheet("*{font: 12pt \"阿里巴巴普惠体 R\";\n"
                                        "font-weight: bold;\n"
                                        "color:blue;}")
        self.line_gateway.setObjectName("line_gateway")
        self.label_mainboard_id = QtWidgets.QLabel(self.tab_2)
        self.label_mainboard_id.setGeometry(QtCore.QRect(50, 390, 101, 16))
        self.label_mainboard_id.setObjectName("label_mainboard_id")
        self.mainboard_id = QtWidgets.QLineEdit(self.tab_2)
        self.mainboard_id.setGeometry(QtCore.QRect(150, 380, 221, 31))
        self.mainboard_id.setStyleSheet("*{font: 12pt \"阿里巴巴普惠体 R\";\n"
                                        "font-weight: bold;\n"
                                        "color:blue;}")
        self.mainboard_id.setObjectName("mainboard_id")
        self.label_dist_id = QtWidgets.QLabel(self.tab_2)
        self.label_dist_id.setGeometry(QtCore.QRect(50, 430, 101, 16))
        self.label_dist_id.setObjectName("label_dist_id")
        self.line_disk_id = QtWidgets.QLineEdit(self.tab_2)
        self.line_disk_id.setGeometry(QtCore.QRect(150, 420, 221, 31))
        self.line_disk_id.setStyleSheet("*{font: 12pt \"阿里巴巴普惠体 R\";\n"
                                        "font-weight: bold;\n"
                                        "color:blue;}")
        self.line_disk_id.setObjectName("line_disk_id")
        self.line_cpu_id = QtWidgets.QLineEdit(self.tab_2)
        self.line_cpu_id.setGeometry(QtCore.QRect(500, 260, 221, 31))
        self.line_cpu_id.setStyleSheet("*{font: 12pt \"阿里巴巴普惠体 R\";\n"
                                       "font-weight: bold;\n"
                                       "color:blue;}")
        self.line_cpu_id.setText("")
        self.line_cpu_id.setObjectName("line_cpu_id")
        self.label_cpu_id = QtWidgets.QLabel(self.tab_2)
        self.label_cpu_id.setGeometry(QtCore.QRect(400, 270, 101, 16))
        self.label_cpu_id.setObjectName("label_cpu_id")
        self.label_cpu_cores = QtWidgets.QLabel(self.tab_2)
        self.label_cpu_cores.setGeometry(QtCore.QRect(400, 310, 101, 16))
        self.label_cpu_cores.setObjectName("label_cpu_cores")
        self.line_cpu_cores = QtWidgets.QLineEdit(self.tab_2)
        self.line_cpu_cores.setGeometry(QtCore.QRect(500, 300, 221, 31))
        self.line_cpu_cores.setStyleSheet("*{font: 12pt \"阿里巴巴普惠体 R\";\n"
                                          "font-weight: bold;\n"
                                          "color:blue;}")
        self.line_cpu_cores.setText("")
        self.line_cpu_cores.setObjectName("line_cpu_cores")
        self.label_memory_info = QtWidgets.QLabel(self.tab_2)
        self.label_memory_info.setGeometry(QtCore.QRect(400, 190, 101, 16))
        self.label_memory_info.setObjectName("label_memory_info")
        self.label_cpu_type = QtWidgets.QLabel(self.tab_2)
        self.label_cpu_type.setGeometry(QtCore.QRect(400, 230, 101, 16))
        self.label_cpu_type.setObjectName("label_cpu_type")
        self.label_sys_version = QtWidgets.QLabel(self.tab_2)
        self.label_sys_version.setGeometry(QtCore.QRect(400, 150, 101, 16))
        self.label_sys_version.setObjectName("label_sys_version")
        self.label_domain_name = QtWidgets.QLabel(self.tab_2)
        self.label_domain_name.setGeometry(QtCore.QRect(400, 110, 101, 16))
        self.label_domain_name.setObjectName("label_domain_name")
        self.line_domain_name = QtWidgets.QLineEdit(self.tab_2)
        self.line_domain_name.setGeometry(QtCore.QRect(500, 100, 221, 31))
        self.line_domain_name.setStyleSheet("*{font: 12pt \"阿里巴巴普惠体 R\";\n"
                                            "font-weight: bold;\n"
                                            "color:blue;}")
        self.line_domain_name.setObjectName("line_domain_name")
        self.sys_version = QtWidgets.QLineEdit(self.tab_2)
        self.sys_version.setGeometry(QtCore.QRect(500, 140, 221, 31))
        self.sys_version.setStyleSheet("*{font: 12pt \"阿里巴巴普惠体 R\";\n"
                                       "font-weight: bold;\n"
                                       "color:blue;}")
        self.sys_version.setObjectName("sys_version")
        self.label_bios_series_no = QtWidgets.QLabel(self.tab_2)
        self.label_bios_series_no.setGeometry(QtCore.QRect(400, 70, 101, 16))
        self.label_bios_series_no.setObjectName("label_bios_series_no")
        self.line_bios_series_no = QtWidgets.QLineEdit(self.tab_2)
        self.line_bios_series_no.setGeometry(QtCore.QRect(500, 60, 221, 31))
        self.line_bios_series_no.setStyleSheet("*{font: 12pt \"阿里巴巴普惠体 R\";\n"
                                               "font-weight: bold;\n"
                                               "color:blue;}")
        self.line_bios_series_no.setObjectName("line_bios_series_no")
        self.line_cpu_type = QtWidgets.QLineEdit(self.tab_2)
        self.line_cpu_type.setGeometry(QtCore.QRect(500, 220, 221, 31))
        self.line_cpu_type.setStyleSheet("*{font: 12pt \"阿里巴巴普惠体 R\";\n"
                                         "font-weight: bold;\n"
                                         "color:blue;}")
        self.line_cpu_type.setObjectName("line_cpu_type")
        self.memory_info = QtWidgets.QLineEdit(self.tab_2)
        self.memory_info.setGeometry(QtCore.QRect(500, 180, 221, 31))
        self.memory_info.setStyleSheet("*{font: 12pt \"阿里巴巴普惠体 R\";\n"
                                       "font-weight: bold;\n"
                                       "color:blue;}")
        self.memory_info.setObjectName("memory_info")
        self.listView_2 = QtWidgets.QListView(self.tab_2)
        self.listView_2.setGeometry(QtCore.QRect(0, 0, 801, 671))
        self.listView_2.setStyleSheet("background:url(:/picture/dartabitlight.jpeg)")
        self.listView_2.setObjectName("listView_2")
        self.line_6 = QtWidgets.QFrame(self.tab_2)
        self.line_6.setGeometry(QtCore.QRect(0, 510, 791, 16))
        self.line_6.setFrameShape(QtWidgets.QFrame.HLine)
        self.line_6.setFrameShadow(QtWidgets.QFrame.Sunken)
        self.line_6.setObjectName("line_6")
        self.line_13 = QtWidgets.QFrame(self.tab_2)
        self.line_13.setGeometry(QtCore.QRect(0, 550, 791, 16))
        self.line_13.setFrameShape(QtWidgets.QFrame.HLine)
        self.line_13.setFrameShadow(QtWidgets.QFrame.Sunken)
        self.line_13.setObjectName("line_13")
        self.line_14 = QtWidgets.QFrame(self.tab_2)
        self.line_14.setGeometry(QtCore.QRect(160, 520, 20, 41))
        self.line_14.setFrameShape(QtWidgets.QFrame.VLine)
        self.line_14.setFrameShadow(QtWidgets.QFrame.Sunken)
        self.line_14.setObjectName("line_14")
        self.line_15 = QtWidgets.QFrame(self.tab_2)
        self.line_15.setGeometry(QtCore.QRect(0, 520, 20, 41))
        self.line_15.setFrameShape(QtWidgets.QFrame.VLine)
        self.line_15.setFrameShadow(QtWidgets.QFrame.Sunken)
        self.line_15.setObjectName("line_15")
        self.listView_2.raise_()
        self.label_version.raise_()
        self.label_computerName.raise_()
        self.line_computerName.raise_()
        self.label_p_13.raise_()
        self.p_13.raise_()
        self.label_ipAdress.raise_()
        self.line_ipAdress.raise_()
        self.label_macAddress.raise_()
        self.macAddress.raise_()
        self.label_subnet_mask.raise_()
        self.subnet_mask.raise_()
        self.label_dns_1.raise_()
        self.line_dns_1.raise_()
        self.label_dns_2.raise_()
        self.line_dns_2.raise_()
        self.label_gateway.raise_()
        self.line_gateway.raise_()
        self.label_mainboard_id.raise_()
        self.mainboard_id.raise_()
        self.label_dist_id.raise_()
        self.line_disk_id.raise_()
        self.line_cpu_id.raise_()
        self.label_cpu_id.raise_()
        self.label_cpu_cores.raise_()
        self.line_cpu_cores.raise_()
        self.label_memory_info.raise_()
        self.label_cpu_type.raise_()
        self.label_sys_version.raise_()
        self.label_domain_name.raise_()
        self.line_domain_name.raise_()
        self.sys_version.raise_()
        self.label_bios_series_no.raise_()
        self.line_bios_series_no.raise_()
        self.line_cpu_type.raise_()
        self.memory_info.raise_()
        self.line_6.raise_()
        self.line_13.raise_()
        self.line_14.raise_()
        self.line_15.raise_()
        icon1 = QtGui.QIcon()
        icon1.addPixmap(QtGui.QPixmap(":/picture/cominfo.jpg"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.tabWidget.addTab(self.tab_2, icon1, "")
        ToolMainWindow.setCentralWidget(self.centralwidget)

        self.retranslateUi(ToolMainWindow)
        self.tabWidget.setCurrentIndex(0)
        QtCore.QMetaObject.connectSlotsByName(ToolMainWindow)
        # 初始化界面
        proxy_ip = cp.get('tools', 'proxy_ip')
        self.lineEdit_proxy_ip_address.setText(proxy_ip)
        proxy_port = cp.get('tools', 'proxy_port')
        self.lineEdit_proxy_port.setText(proxy_port)
        proxy_flag = cp.get('database', 'proxy_flag')
        if proxy_flag == 'on':
            self.radioButton_switch_off.setChecked(False)
            self.radioButton_switch_on.setChecked(True)
        if proxy_flag == 'off':
            self.radioButton_switch_off.setChecked(True)
            self.radioButton_switch_on.setChecked(False)
        c = wmi.WMI()
        tmplist = []
        tmpdictcpuinfo = {}
        encrypt_str = ''
        tmpdictcpuinfo["CpuCores"] = 0
        nic_configs = c.Win32_NetworkAdapterConfiguration(IPEnabled=True)
        nic = nic_configs[0]
        w = psutil.virtual_memory()
        # 首选得到生产IP地址,这个地址绝对不会有错
        ip = nic.IPAddress[0]
        for cpu in c.Win32_Processor():
            # cpu 序列号
            encrypt_str = encrypt_str + cpu.ProcessorId.strip()
            cpuId = cpu.ProcessorId.strip()
            cpuType = cpu.Name
            tmpdictcpuinfo["CpuType"] = cpuType
            try:
                cpuCores = cpu.NumberOfCores
                tmpdictcpuinfo["CpuCores"] = cpu.NumberOfCores
            except RequestException:
                tmpdictcpuinfo["CpuCores"] += 1
                tmpdictcpuinfo["CpuClock"] = cpu.MaxClockSpeed
        for physical_disk in c.Win32_DiskDrive():
            encrypt_str = encrypt_str + physical_disk.SerialNumber.strip()

            # 硬盘序列号
            diskId = physical_disk.SerialNumber.strip()
            tmpdict = {"DiskId": diskId, "Caption": physical_disk.Caption,
                       "Size": int(physical_disk.Size) / 1000 / 1000 / 1000}
            tmplist.append(tmpdict)
        for board_id in c.Win32_BaseBoard():
            # 主板序列号
            encrypt_str = encrypt_str + board_id.SerialNumber.strip()
            mainBoardId = board_id.SerialNumber.strip()
        for bios_id in c.Win32_BIOS():
            # bios 序列号
            encrypt_str = encrypt_str + bios_id.SerialNumber.strip()
            biosNumber = bios_id.SerialNumber.strip()
        content = {'p13': os.getlogin(),
                   'ip': ip,
                   'hostName': nic.DNSHostName,
                   'mac': nic.MACAddress,
                   'mask': nic.IPSubnet[0],
                   'dns': ','.join(nic.DNSServerSearchOrder),
                   'gate': nic.DefaultIPGateway[0],
                   'mainBoardId': mainBoardId,
                   'diskId': diskId,
                   'diskCaption': " ".join('%s' % c for c in tmplist),
                   'cpuId': cpuId,
                   'cpuType': tmpdictcpuinfo['CpuType'],
                   'cpuCores': tmpdictcpuinfo['CpuCores'],
                   'biosNumber': biosNumber,
                   'domainName': nic.DNSDomainSuffixSearchOrder,
                   'osversion': " ".join('%s' % a for a in sys.getwindowsversion()),
                   'memoryinfo': w.total / 1024 / 1024 / 1024
                   }
        # content = json.dumps(content)
        headers = {'Content-Type': 'application/json'}
        json_data = json.dumps(content)  # 把information数据写到json文件中
        info = json.loads(json_data)  # python读取json数据

        # *************窗体形式显示*************#
        self.lineEdit_ip_address.setText(info['ip'])
        self.lineEdit_subnet_mask.setText(info['mask'])
        self.lineEdit_default_gateway.setText(info['gate'])
        self.lineEdit_dns_1.setText(nic.DNSServerSearchOrder[0])
        dns_2 = ''
        if len(nic.DNSServerSearchOrder) > 1:
            dns_2 = nic.DNSServerSearchOrder[1]
        self.lineEdit_dns_2.setText(dns_2)
        self.line_computerName.setText(info['hostName'])
        self.p_13.setText(info['p13'])
        self.line_ipAdress.setText(info['ip'])
        self.macAddress.setText(info['mac'])
        self.subnet_mask.setText(info['mask'])
        self.line_dns_1.setText(nic.DNSServerSearchOrder[0])
        self.line_dns_2.setText(dns_2)
        self.line_gateway.setText(info['gate'])
        self.mainboard_id.setText(info['mainBoardId'])
        self.line_disk_id.setText(info['diskId'])
        self.line_bios_series_no.setText("%s" % info['biosNumber'])
        domainName = info['domainName']
        self.line_domain_name.setText(domainName[0])
        self.sys_version.setText(info['osversion'])
        strnum = info['memoryinfo']
        num33 = round(float(strnum))
        self.memory_info.setText(str(num33) + 'G')
        self.line_cpu_type.setText(info['cpuType'])
        self.line_cpu_id.setText(info['cpuId'])
        self.line_cpu_cores.setText("%s" % info['cpuCores'])
        # *************窗体形式显示*************#
        # *************槽方法*************#
        self.radioButton_all.clicked.connect(lambda: func_impl.FuncImpl.radioBtn_all(self))
        self.radioButton_cancel_all.clicked.connect(lambda: func_impl.FuncImpl.radioBtn_cancel_all(self))
        self.radioButton_switch_on.clicked.connect(lambda: func_impl.FuncImpl.radioBtn_switch_on(self))
        self.radioButton_switch_off.clicked.connect(lambda: func_impl.FuncImpl.radioBtn_switch_off(self))
        self.pushButton_onepush.clicked.connect(lambda: Ui_ToolMainWindow.pushBtn_onepush(self))
        self.pushButton_software_download.clicked.connect(lambda: func_impl.FuncImpl.download_addr_open(cp))

        # *************槽方法*************#

    def pushBtn_onepush(self):
        if self.checkBox_restart_print_service.isChecked():
            file_path = root_path + cp.get('tools', 'restart_print_service_path')
            win32api.ShellExecute(0, 'open', file_path, '', '', 1)  # 前台打开
            # QMessageBox.about(self, '提示', '重启打印服务')
        if self.checkBox_ie_set.isChecked():
            file_path = root_path + cp.get('tools', 'ie_set_path')
            win32api.ShellExecute(0, 'open', file_path, '', '', 1)  # 前台打开
            # QMessageBox.about(self, '提示', '公司IE设置')
        if self.checkBox_clear_all_tasks.isChecked():
            file_path = root_path + cp.get('tools', 'clear_all_tasks_path')
            win32api.ShellExecute(0, 'open', file_path, '', '', 1)  # 前台打开
            # QMessageBox.about(self, '提示', '清除所有计划任务')
        if self.checkBox_fix_dns.isChecked():
            Ui_ToolMainWindow.ipconfig_set_bat_in_file_write(self)
            file_path = root_path + cp.get('tools', 'fix_dns_path')
            win32api.ShellExecute(0, 'open', file_path, '', '', 1)  # 前台打开
            # QMessageBox.about(self, '提示', '公司DNS修复')
        if self.checkBox_c_clear.isChecked():
            function_impl.delete_files(self)
            # QMessageBox.about(self, '提示', 'C盘清理')
        if self.checkBox_host_domain_map.isChecked():
            source = root_path + cp.get('tools', 'hosts_script_path')
            target = cp.get('tools', 'hosts_path_file')
            try:
                copyfile(source, target)
                # QMessageBox.about(self, '提示', 'host常用域名映射成功!')
            except IOError as e:
                QMessageBox.about(self, '提示', "Unable to copy file. %s" % e)
            except:
                QMessageBox.about(self, '提示', "Unexpected error:", sys.exc_info())
        if self.checkBox_update_AD_domain_strategy.isChecked():
            file_path = root_path + cp.get('tools', 'update_ad_domain_strategy_path')
            win32api.ShellExecute(0, 'open', file_path, '', '', 1)  # 前台打开
            # QMessageBox.about(self, '提示', '更新AD域策略')
        QMessageBox.about(self, '提示', '优化完成')

    def ipconfig_set_bat_in_file_write(self):
        ip_address_str = self.lineEdit_ip_address.text()
        subnet_mask_str = self.lineEdit_subnet_mask.text()
        default_gateway_str = self.lineEdit_default_gateway.text()
        dns_1_str = self.lineEdit_dns_1.text()
        dns_2_str = self.lineEdit_dns_2.text()
        dns_host_name = '以太网'
        content = u'@echo off\nnetsh interface ip set address "以太网" static ' + ip_address_str + ' ' + subnet_mask_str + ' ' + default_gateway_str + '\nnetsh interface ip set dns "' + dns_host_name + '"  static ' + dns_1_str + ' validate=no\nnetsh interface ip add dns "' + dns_host_name + '" ' + dns_2_str + ' validate=no\nipconfig /flushdns\npause\nexit\n'
        cp.set('database', 'ip_address_str', ip_address_str)  # 使用set直接修改指定字段值
        cp.set('database', 'subnet_mask_str', subnet_mask_str)  # 使用set直接修改指定字段值
        cp.set('database', 'default_gateway_str', default_gateway_str)  # 使用set直接修改指定字段值
        cp.set('database', 'dns_1_str', dns_1_str)  # 使用set直接修改指定字段值
        cp.set('database', 'dns_2_str', dns_2_str)  # 使用set直接修改指定字段值
        with open('config.cfg', 'w+') as f:
            cp.write(f)
        Ui_ToolMainWindow.bat_in_file_write_flexible_encode(self, 'script/ipconfig_set.bat', content, 'ANSI')

    def bat_in_file_writelines_flexible(self, file_name, file_content_array):
        Note = open(file_name, mode='w')
        Note.writelines(file_content_array)  # \n 换行符
        Note.close()

    def bat_in_file_write_flexible_encode(self, filename, content, encoding_type):
        with open(filename, 'w', encoding=encoding_type) as f:
            f.write(content)

    def retranslateUi(self, ToolMainWindow):
        _translate = QtCore.QCoreApplication.translate
        ToolMainWindow.setWindowTitle(_translate("ToolMainWindow", "小工具"))
        self.checkBox_ie_set.setText(_translate("ToolMainWindow", "公司IE设置"))
        self.checkBox_host_domain_map.setText(_translate("ToolMainWindow", "host常用域名映射"))
        self.checkBox_c_clear.setText(_translate("ToolMainWindow", "C盘清理"))
        self.checkBox_restart_print_service.setText(_translate("ToolMainWindow", "重启打印服务"))
        self.checkBox_clear_all_tasks.setText(_translate("ToolMainWindow", "清除所有计划任务"))
        self.checkBox_fix_dns.setText(_translate("ToolMainWindow", "公司DNS修复"))
        self.checkBox_update_AD_domain_strategy.setText(_translate("ToolMainWindow", "更新AD域策略"))
        self.label_proxy_ip_address.setText(_translate("ToolMainWindow", "代理IP地址:"))
        self.label_proxy_port.setText(_translate("ToolMainWindow", "代理端口:"))
        self.label_dns_4.setText(_translate("ToolMainWindow", "首选DNS:"))
        self.label_default_gateway.setText(_translate("ToolMainWindow", "默认网关:"))
        self.label_subnet_mask_2.setText(_translate("ToolMainWindow", "子网掩码:"))
        self.label_ip_address.setText(_translate("ToolMainWindow", "IP地址:"))
        self.label_dns_3.setText(_translate("ToolMainWindow", "备用DNS:"))
        self.pushButton_software_download.setText(_translate("ToolMainWindow", "常用软件下载地址"))
        self.pushButton_onepush.setText(_translate("ToolMainWindow", "一键优化"))
        self.label_version_1.setText(_translate("ToolMainWindow", "当前版本:cx1.0v"))
        self.radioButton_switch_off.setText(_translate("ToolMainWindow", "关"))
        self.radioButton_switch_on.setText(_translate("ToolMainWindow", "开"))
        self.radioButton_cancel_all.setText(_translate("ToolMainWindow", "取消全选"))
        self.radioButton_all.setText(_translate("ToolMainWindow", "全选"))
        self.label.setText(_translate("ToolMainWindow", "代理开关:"))
        self.label_version.setText(_translate("ToolMainWindow", "当前版本:cx1.0v"))
        self.label_computerName.setText(_translate("ToolMainWindow", "计算机名:"))
        self.label_p_13.setText(_translate("ToolMainWindow", "用户名:"))
        self.label_ipAdress.setText(_translate("ToolMainWindow", "IP:"))
        self.label_macAddress.setText(_translate("ToolMainWindow", "mac地址:"))
        self.label_subnet_mask.setText(_translate("ToolMainWindow", "掩码: "))
        self.label_dns_1.setText(_translate("ToolMainWindow", "首选DNS:"))
        self.label_dns_2.setText(_translate("ToolMainWindow", "备用DNS:"))
        self.label_gateway.setText(_translate("ToolMainWindow", "网关:"))
        self.label_mainboard_id.setText(_translate("ToolMainWindow", "主板id: "))
        self.label_dist_id.setText(_translate("ToolMainWindow", "硬盘id:"))
        self.label_cpu_id.setText(_translate("ToolMainWindow", "cpuId: "))
        self.label_cpu_cores.setText(_translate("ToolMainWindow", "cpu核数: "))
        self.label_memory_info.setText(_translate("ToolMainWindow", "内存信息:"))
        self.label_cpu_type.setText(_translate("ToolMainWindow", "cpu类型:"))
        self.label_sys_version.setText(_translate("ToolMainWindow", "系统版本:"))
        self.label_domain_name.setText(_translate("ToolMainWindow", "域名: "))
        self.label_bios_series_no.setText(_translate("ToolMainWindow", "bios序列号: "))


import picture_rc

picture.qrc为图片资源库,通过PyRcc5转化为?picture_rc.py

picture.qrc

<!DOCTYPE RCC>
<RCC version="1.0">
<qresource prefix="/">
    <file>picture/light.jpeg</file>
    <file>picture/cutecartoon.jpeg</file>
    <file>picture/crossandroad.jpeg</file>
    <file>picture/dartabitlight.jpeg</file>
    <file>picture/horizen.jpeg</file>
    <file>picture/crossandroad.jpeg</file>
    <file>picture/crossandroad.jpeg</file>
    <file>picture/spyder.ico</file>
    <file>picture/优化.jpeg</file>
    <file>picture/本机信息.jpg</file>
    <file>picture/cominfo.jpg</file>
    <file>picture/sys.jpg</file>
</qresource>
</RCC>

?function_impl.py 功能方法实现

import json
import os
import re  # 正则
import sys
import winreg
from configparser import ConfigParser
from tkinter import *
import psutil
import requests
import win32api
import wmi
from PyQt5.QtWidgets import QMessageBox
from requests import RequestException
from os import listdir
from time import sleep
from wmi import WMI
import tkinter

cp = ConfigParser()
cp.read('config.cfg')


def btnFunc(self, nm):
    QMessageBox.about(self, '测试键', nm)


# 表项路径
xpath = cp.get('tools', 'xpath')


# 设定代理,enable:是否开启,proxyIp:代理服务器ip及端口,IgnoreIp:忽略代理的ip或网址
def setProxy(self, enable, proxyIp, IgnoreIp):
    try:
        key = winreg.OpenKey(winreg.HKEY_CURRENT_USER, xpath, 0, winreg.KEY_WRITE)
        winreg.SetValueEx(key, "ProxyEnable", 0, winreg.REG_DWORD, enable)
        winreg.SetValueEx(key, "ProxyServer", 0, winreg.REG_SZ, proxyIp)
        winreg.SetValueEx(key, "ProxyOverride", 0, winreg.REG_SZ, IgnoreIp)
    except Exception as e:
        QMessageBox.about(self, "ERROR: " + str(e.args))
    finally:
        None


# 开启,定义代理服务器ip及端口,忽略ip内容(分号分割)
def enableProxy(self):
    proxyIP = cp.get('tools', 'proxy_ip') + ':' + cp.get('tools', 'proxy_port')
    IgnoreIp = cp.get('tools', 'ignore_ip')
    setProxy(self, 1, proxyIP, IgnoreIp)
    cp.set("database", "proxy_flag", "on")  # 使用set直接修改指定字段值
    with open("config.cfg", "w+") as f:
        cp.write(f)
    QMessageBox.about(self, '代理设置', '已开启代理!')


# 关闭清空代理
def disableProxy(self):
    setProxy(self, 0, "", "")
    cp.set("database", "proxy_flag", "off")  # 使用set直接修改指定字段值
    with open("config.cfg", "w+") as f:
        cp.write(f)
    QMessageBox.about(self, '代理设置', '已关闭代理!')


def proxyFunc(self, place):
    try:
        if place == "off":
            disableProxy(self)
        if place == "on":
            enableProxy(self)
    except Exception as e:
        QMessageBox.about(self, "ERROR: " + str(e.args))
    finally:
        pass


def registerDll(self):
    dll_path = cp.get('tools', 'dll_path')
    dll_path_array = dll_path.split(';')
    for x in dll_path_array:
        win32api.ShellExecute(0, 'open', x, '', '', 1)  # 前台打开


def send_info(self, send_switch):
    c = wmi.WMI()
    tmplist = []
    tmpdictcpuinfo = {}
    encrypt_str = ''
    tmpdictcpuinfo["CpuCores"] = 0
    nic_configs = c.Win32_NetworkAdapterConfiguration(IPEnabled=True)
    nic = nic_configs[0]
    w = psutil.virtual_memory()
    # 首选得到生产IP地址,这个地址绝对不会有错
    ip = nic.IPAddress[0]
    for cpu in c.Win32_Processor():
        # cpu 序列号
        encrypt_str = encrypt_str + cpu.ProcessorId.strip()
        cpuId = cpu.ProcessorId.strip()
        cpuType = cpu.Name
        tmpdictcpuinfo["CpuType"] = cpuType
        try:
            cpuCores = cpu.NumberOfCores
            tmpdictcpuinfo["CpuCores"] = cpu.NumberOfCores
        except RequestException:
            tmpdictcpuinfo["CpuCores"] += 1
            tmpdictcpuinfo["CpuClock"] = cpu.MaxClockSpeed
    for physical_disk in c.Win32_DiskDrive():
        encrypt_str = encrypt_str + physical_disk.SerialNumber.strip()

        # 硬盘序列号
        diskId = physical_disk.SerialNumber.strip()
        tmpdict = {"DiskId": diskId, "Caption": physical_disk.Caption,
                   "Size": int(physical_disk.Size) / 1000 / 1000 / 1000}
        tmplist.append(tmpdict)
    for board_id in c.Win32_BaseBoard():
        # 主板序列号
        encrypt_str = encrypt_str + board_id.SerialNumber.strip()
        mainBoardId = board_id.SerialNumber.strip()
    for bios_id in c.Win32_BIOS():
        # bios 序列号
        encrypt_str = encrypt_str + bios_id.SerialNumber.strip()
        biosNumber = bios_id.SerialNumber.strip()
    content = {'p13': os.getlogin(),
               'ip': ip,
               'hostName': nic.DNSHostName,
               'mac': nic.MACAddress,
               'mask': nic.IPSubnet[0],
               'dns': ','.join(nic.DNSServerSearchOrder),
               'gate': nic.DefaultIPGateway[0],
               'mainBoardId': mainBoardId,
               'diskId': diskId,
               'diskCaption': " ".join('%s' % c for c in tmplist),
               'cpuId': cpuId,
               'cpuType': tmpdictcpuinfo['CpuType'],
               'cpuCores': tmpdictcpuinfo['CpuCores'],
               'biosNumber': biosNumber,
               'domainName': nic.DNSDomainSuffixSearchOrder,
               'osversion': " ".join('%s' % a for a in sys.getwindowsversion()),
               'memoryinfo': w.total / 1024 / 1024 / 1024
               }
    # content = json.dumps(content)
    headers = {'Content-Type': 'application/json'}
    json_data = json.dumps(content)  # 把information数据写到json文件中
    info = json.loads(json_data)  # python读取json数据

    # *************窗体形式显示*************#
    root1 = Tk()
    root1.resizable(width=False, height=False)
    root1.title("计算机信息")
    root1.geometry('550x580+700+250')
    dtxt = Label(root1, text='用户名:', fg='black')
    dtxt.grid(column=1, row=1)  # row 表示行,colum表示列
    dred = tkinter.Entry(root1, width=40)
    dred.delete(0, "end")
    dred.insert(0, info['p13'])
    # dred = Label(root1, text=("%s" % info['p13']), fg='black')
    dred.grid(column=2, row=1)

    xdia = Label(root1, text='ip:', fg='black')
    xdia.grid(column=1, row=2)
    # xdib = Label(root1, text=("%s" % info['ip']), fg='blue')
    xdib = tkinter.Entry(root1, width=40)
    xdib.delete(0, "end")
    xdib.insert(0, info['ip'])
    xdib.grid(column=2, row=2)

    skia = Label(root1, text='计算机名:', fg='black')
    skia.grid(column=1, row=3)
    # skib = Label(root1, text=("%s" % info['hostName']), fg='black')
    skib = tkinter.Entry(root1, width=40)
    skib.delete(0, "end")
    skib.insert(0, info['hostName'])
    skib.grid(column=2, row=3)

    hkia = Label(root1, text='mac地址:', fg='black')
    hkia.grid(column=1, row=4)
    # hkib = Label(root1, text=("%s" % info['mac']), fg='black')
    hkib = tkinter.Entry(root1, width=40)
    hkib.delete(0, "end")
    hkib.insert(0, info['mac'])
    hkib.grid(column=2, row=4)

    ltia = Label(root1, text='掩码: ', fg='black')
    ltia.grid(column=1, row=5)
    # ltib = Label(root1, text=("%s" % info['mask']), fg='red')
    ltib = tkinter.Entry(root1, width=40)
    ltib.delete(0, "end")
    ltib.insert(0, info['mask'])
    ltib.grid(column=2, row=5)

    dnsa = Label(root1, text='dns: ', fg='black')
    dnsa.grid(column=1, row=6)
    # dnsb = Label(root1, text=("%s" % info['dns']), fg='red')
    dnsb = tkinter.Entry(root1, width=40)
    dnsb.delete(0, "end")
    dnsb.insert(0, info['dns'])
    dnsb.grid(column=2, row=6)

    gatea = Label(root1, text='网关: ', fg='black')
    gatea.grid(column=1, row=7)
    # gateb = Label(root1, text=("%s" % info['gate']), fg='red')
    gateb = tkinter.Entry(root1, width=40)
    gateb.delete(0, "end")
    gateb.insert(0, info['gate'])
    gateb.grid(column=2, row=7)

    mainBoardIda = Label(root1, text='主板id: ', fg='black')
    mainBoardIda.grid(column=1, row=8)
    # mainBoardIdb = Label(root1, text=("%s" % info['mainBoardId']), fg='red')
    mainBoardIdb = tkinter.Entry(root1, width=40)
    mainBoardIdb.delete(0, "end")
    mainBoardIdb.insert(0, info['mainBoardId'])
    mainBoardIdb.grid(column=2, row=8)

    diskIda = Label(root1, text='硬盘id: ', fg='black')
    diskIda.grid(column=1, row=9)
    # diskIdb = Label(root1, text=("%s" % info['diskId']), fg='red')
    diskIdb = tkinter.Entry(root1, width=40)
    diskIdb.delete(0, "end")
    diskIdb.insert(0, info['diskId'])
    diskIdb.grid(column=2, row=9)

    cpuIda = Label(root1, text='cpuId: ', fg='black')
    cpuIda.grid(column=1, row=10)
    # cpuIdb = Label(root1, text=("%s" % info['cpuId']), fg='red')
    cpuIdb = tkinter.Entry(root1, width=40)
    cpuIdb.delete(0, "end")
    cpuIdb.insert(0, info['cpuId'])
    cpuIdb.grid(column=2, row=10)

    cpuCoresa = Label(root1, text='cpu核数: ', fg='black')
    cpuCoresa.grid(column=1, row=11)
    # cpuCoresb = Label(root1, text=("%s" % info['cpuCores']), fg='red')
    cpuCoresb = tkinter.Entry(root1, width=40)
    cpuCoresb.delete(0, "end")
    cpuCoresb.insert(0, info['cpuCores'])
    cpuCoresb.grid(column=2, row=11)

    ltibiosNumbera = Label(root1, text='bios序列号: ', fg='black')
    ltibiosNumbera.grid(column=1, row=12)
    # ltibiosNumberb = Label(root1, text=("%s" % info['biosNumber']), fg='red')
    ltibiosNumberb = tkinter.Entry(root1, width=40)
    ltibiosNumberb.delete(0, "end")
    ltibiosNumberb.insert(0, info['biosNumber'])
    ltibiosNumberb.grid(column=2, row=12)

    ltidomainNamea = Label(root1, text='域名: ', fg='black')
    ltidomainNamea.grid(column=1, row=13)
    # ltidomainNameb = Label(root1, text=("%s" % info['domainName']), fg='red')
    ltidomainNameb = tkinter.Entry(root1, width=40)
    ltidomainNameb.delete(0, "end")
    ltidomainNameb.insert(0, info['domainName'])
    ltidomainNameb.grid(column=2, row=13)

    ltiosversiona = Label(root1, text='系统版本: ', fg='black')
    ltiosversiona.grid(column=1, row=15)
    # ltiosversionb = Label(root1, text=("%s" % info['osversion']), fg='red')
    ltiosversionb = tkinter.Entry(root1, width=40)
    ltiosversionb.delete(0, "end")
    ltiosversionb.insert(0, info['osversion'])
    ltiosversionb.grid(column=2, row=15)

    ltimemoryinfoa = Label(root1, text='内存信息: ', fg='black')
    ltimemoryinfoa.grid(column=1, row=16)
    # ltimemoryinfob = Label(root1, text=("%s" % info['memoryinfo']), fg='red')
    ltimemoryinfob = tkinter.Entry(root1, width=40)
    ltimemoryinfob.delete(0, "end")
    ltimemoryinfob.insert(0, info['memoryinfo'])
    ltimemoryinfob.grid(column=2, row=16)

    lticputypeinfoa = Label(root1, text='cpu类型: ', fg='black')
    lticputypeinfoa.grid(column=1, row=17)
    # ltimemoryinfob = Label(root1, text=("%s" % info['memoryinfo']), fg='red')
    lticputypeinfob = tkinter.Entry(root1, width=40)
    lticputypeinfob.delete(0, "end")
    lticputypeinfob.insert(0, info['cpuType'])
    lticputypeinfob.grid(column=2, row=17)
    if send_switch == 'on':
        try:
            # 发送请求
            r = requests.post(url, headers=headers, data=json_data)
            a = json.loads(r.text)
            if a:
                QMessageBox.about(self, '计算机信息发送', '发送成功!点击ok显示本机信息。')
            else:
                QMessageBox.about(self, '计算机信息发送', '发送失败!!点击ok显示本机信息。')
        except RequestException:
            QMessageBox.about(self, '计算机信息发送', '发送失败!!点击ok显示本机信息。')
    root1.mainloop()  # 窗体显示


def delete_files(self):
    delete_path = cp.get('tools', 'delete_path')
    delete_file_type = cp.get('tools', 'delete_file_type')
    for file_name in listdir(delete_path):
        if file_name.endswith(delete_file_type):
            try:
                os.remove(delete_path + file_name)
            except Exception as e:
                continue
    QMessageBox.about(self, '删除', '删除成功!')


def set_ip(self):
    nic_configs = wmi.WMI().Win32_NetworkAdapterConfiguration(IPEnabled=True)
    # First network adaptor
    nic = nic_configs[0]
    ip = var_ip.get()
    subnetmask = var_mask.get()
    gateway = var_gateway.get()

    # Set IP address, subnet mask and default gateway
    a = nic.EnableStatic(IPAddress=[ip], SubnetMask=[subnetmask])
    b = nic.SetGateways(DefaultIPGateway=[gateway])


def set_ip_dns(self):
    wmiService = wmi.WMI()
    colNicConfigs = wmiService.Win32_NetworkAdapterConfiguration(IPEnabled=True)
    # for objNicConfig in colNicConfigs:
    if len(colNicConfigs) < 1:
        QMessageBox.about(self, '提醒', '没有找到可用的网络适配器')
        exit()
    objNicConfig = colNicConfigs[0]
    arrIPAddresse = cp.get('tools', 'arr_ip_addresses')
    arr_ip_addresses = [arrIPAddresse]
    arrSubnetMask = cp.get('tools', 'arr_subnet_masks')
    arr_subnet_masks = [arrSubnetMask]
    arrDefaultGateway = cp.get('tools', 'arr_default_gateways')
    arrDefaultGateways = [arrDefaultGateway]
    arrGatewayCostMetrics = [1]
    arrDNSServer = cp.get('tools', 'arr_dns_servers')
    arrDNSServers = [arrDNSServer]
    intReboot = 0
    returnValue = objNicConfig.EnableStatic(IPAddress=arr_ip_addresses, SubnetMask=arr_subnet_masks)
    if returnValue[0] == 0:
        QMessageBox.about(self, '提示', '设置IP成功')
    elif returnValue[0] == 1:
        QMessageBox.about(self, '提示', '设置IP成功')
        intReboot += 1
    else:
        QMessageBox.about(self, '提示', '修改IP失败: IP设置发生错误')
        exit()
        returnValue = objNicConfig.SetGateways(DefaultIPGateway=arrDefaultGateways,
                                               GatewayCostMetric=arrGatewayCostMetrics)
    if returnValue[0] == 0:
        QMessageBox.about(self, '提示', '设置网关成功')
    elif returnValue[0] == 1:
        QMessageBox.about(self, '提示', '设置网关成功')
        intReboot += 1
    else:
        QMessageBox.about(self, '提示', '修改IP失败: 网关设置发生错误')
        exit()
    returnValue = objNicConfig.SetDNSServerSearchOrder(DNSServerSearchOrder=arrDNSServers)
    if returnValue[0] == 0:
        QMessageBox.about(self, '提示', '设置DNS成功')
    elif returnValue[0] == 1:
        QMessageBox.about(self, '提示', '设置DNS成功')
        intReboot += 1
    else:
        QMessageBox.about(self, '提示', '修改IP失败: DNS设置发生错误')
        exit()
    if intReboot > 0:
        QMessageBox.about(self, '提示', '需要重新启动计算机')
    else:
        QMessageBox.about(self, '提示', '修改IP结束')


# 随机修改指定ip段的本机ip
def getAdapter(self):
    wmiService = WMI()
    # 获取到本地有网卡信息
    colNicConfigs = wmiService.Win32_NetworkAdapterConfiguration(IPEnabled=True)
    flag = 0
    # 遍历所有网卡,找到要修改的那个,这里我是用原ip的第一段正则出来的
    for obj in colNicConfigs:
        ip = re.findall("10.\d+.\d+.\d+", obj.IPAddress[0])
        if len(ip) > 0:
            return flag
        else:
            flag = flag + 1


def runSet(self):
    wmiService = WMI()
    # 获取到本地有网卡信息
    colNicConfigs = wmiService.Win32_NetworkAdapterConfiguration(IPEnabled=True)
    adapter = colNicConfigs[getAdapter()]
    arrIPAddresse = cp.get('tools', 'arr_ip_addresses')
    arrSubnetMask = cp.get('tools', 'arr_subnet_masks')
    arrDefaultGateway = cp.get('tools', 'arr_default_gateways')
    arrDNSServer = cp.get('tools', 'arr_dns_servers')
    newIP = arrIPAddresse
    arr_ip_addresses = [newIP]  # 设置新的ip
    arr_subnet_masks = [arrSubnetMask]  # 子网掩码
    arrDefaultGateways = [arrDefaultGateway]  # 网关
    arrGatewayCostMetrics = [1]  # 这里要设置成1,代表非自动选择
    arrDNSServers = [arrDNSServer]  # dns服务器
    # 开始执行修改ip、子网掩码、网关
    ipRes = adapter.EnableStatic(IPAddress=arr_ip_addresses, SubnetMask=arr_subnet_masks)
    if ipRes[0] == 0:
        QMessageBox.about(self, '提示', 'ip:设置IP成功当前ip:' + newIP)
    else:
        if ipRes[0] == 1:
            QMessageBox.about(self, '提示', 'ip:设置IP成功,需要重启计算机!')
        else:
            QMessageBox.about(self, '提示', 'ip:修改IP失败: IP设置发生错误!')
            return False
    # 开始执行修改dns
    wayRes = adapter.SetGateways(DefaultIPGateway=arrDefaultGateways, GatewayCostMetric=arrGatewayCostMetrics)
    if wayRes[0] == 0:
        QMessageBox.about(self, '提示', 'ip:设置网关成功')
    else:
        QMessageBox.about(self, '提示', 'ip:修改网关失败: 网关设置发生错误')
        return False
    dnsRes = adapter.SetDNSServerSearchOrder(DNSServerSearchOrder=arrDNSServers)
    if dnsRes[0] == 0:
        QMessageBox.about(self, '提示', 'ip:设置DNS成功,等待3秒刷新缓存')
        sleep(3)
        # 刷新DNS缓存使DNS生效
        os.system('ipconfig /flushdns')
    else:
        QMessageBox.about(self, '提示', 'ip:修改DNS失败: DNS设置发生错误')
        return False


'''
  //ping某ip看是否可以通
  def pingIP(self, ip):
    res = os.popen('ping -n 2 -w 1 %s' % ip).read() #内容返回到res
    res = res.decode('gbk')
    if u'请求超时' in res:     #注意乱码编码问题
       return False
    else:
      return True
'''


def update_ip_dns(self):
    runSet(self)
    input()

func_impl.py功能方法实现

import os
from configparser import ConfigParser

import win32api
from PyQt5.QtWidgets import QMessageBox

import function_impl

cp = ConfigParser()
cp.read('config.cfg')


class FuncImpl:
    def radioBtn_all(self):
        if self.radioButton_all.isChecked():
            self.checkBox_restart_print_service.setChecked(True)
            self.checkBox_ie_set.setChecked(True)
            self.checkBox_clear_all_tasks.setChecked(True)
            self.checkBox_fix_dns.setChecked(True)
            self.checkBox_c_clear.setChecked(True)
            self.checkBox_host_domain_map.setChecked(True)
            self.checkBox_update_AD_domain_strategy.setChecked(True)

    def radioBtn_cancel_all(self):
        if self.radioButton_cancel_all.isChecked():
            self.checkBox_restart_print_service.setChecked(False)
            self.checkBox_ie_set.setChecked(False)
            self.checkBox_clear_all_tasks.setChecked(False)
            self.checkBox_fix_dns.setChecked(False)
            self.checkBox_c_clear.setChecked(False)
            self.checkBox_host_domain_map.setChecked(False)
            self.checkBox_update_AD_domain_strategy.setChecked(False)

    def radioBtn_switch_on(self):
        function_impl.enableProxy(self)

    def radioBtn_switch_off(self):
        function_impl.disableProxy(self)

    def pushBtn_onepush(self):
        if self.checkBox_restart_print_service.isChecked():
            dll_path = cp.get('tools', 'dll_path')
            dll_path_array = dll_path.split(';')
            for x in dll_path_array:
                win32api.ShellExecute(0, 'open', x, '', '', 1)  # 前台打开
            QMessageBox.about(self, '提示', '重启打印服务')
        if self.checkBox_ie_set.isChecked():
            QMessageBox.about(self, '提示', '公司IE设置')
        if self.checkBox_clear_all_tasks.isChecked():
            QMessageBox.about(self, '提示', '清除所有计划任务')
        if self.checkBox_fix_dns.isChecked():
            QMessageBox.about(self, '提示', '公司DNS修复')
        if self.checkBox_c_clear.isChecked():
            function_impl.delete_files(self)
            QMessageBox.about(self, '提示', 'C盘清理')
        if self.checkBox_host_domain_map.isChecked():
            QMessageBox.about(self, '提示', 'host常用域名映射')
        if self.checkBox_update_AD_domain_strategy.isChecked():
            QMessageBox.about(self, '提示', '更新AD域策略')

    @staticmethod
    def download_addr_open(cp):
        browser_package_path = cp.get('tools', 'browser_package_path')
        os.system(browser_package_path)

配置文件 config.cfg

[tools]
send_url = http://10.13.1.92:31001/gateway/computerInfoCollect
xpath = Software\Microsoft\Windows\CurrentVersion\Internet Settings
dll_path = C:/Users/Administrator/Desktop/pyfile/test.bat;C:/Users/Administrator/Desktop/pyfile/test.bat
proxy_ip = 10.13.46.101
proxy_port = 8080
picture_path = gg.jpg
ignore_ip = 10.*;11.*;172.16.13.*;29.*;25.*;26.*;21.*;*exy.cpic.com.cn;*pxb.cpic.com.cn;*.oa.net;*.cpic.com;*.cxcq.cpic.com.cn;developer.cpic.com.cn;dcms.tb.com.cn;cpicmail.cpic.com.cn
delete_path = C:\Windows\System32\winevt\Logs\
delete_file_type = .evtx
arr_ip_addresses = 10.13.1.92
arr_subnet_masks = 255.255.255.0
arr_default_gateways = 10.13.1.254
arr_gateway_cost_metrics = 1
arr_dns_servers = 10.183.16.200
browser_package_path = "C:\Program Files\Google\Chrome\Application\chrome.exe" http://10.13.0.67:5000/
restart_print_service_path = \script\restart_print_service.bat
ie_set_path = \script\ie_set.bat
clear_all_tasks_path = \script\delete_all_planed_tasks.bat
fix_dns_path = \script\ipconfig_set.bat
host_domain_map_path = \script\ipconfig_set.bat
update_ad_domain_strategy_path = \script\update_strategy.bat
hosts_path_file = C:/Windows/System32/drivers/etc/hosts
hosts_script_path = \script\hosts

[database]
proxy_flag = off
ip_address_str = 10.13.1.92
subnet_mask_str = 255.255.255.0
default_gateway_str = 10.13.1.254
dns_1_str = 10.183.16.200
dns_2_str = 10.193.16.105
root_path = E:\pythonProgram\pipenv\tool

脚本文件

delete_all_planed_tasks.bat

schtasks /Delete /TN * /F

ie_set.bat

echo off
title    ��  IE ActiveX ������y?�   ��
cls
echo.

echo	���?��� �� ����Cookies�������?������� �� ������....

rem �������Cookies
@Rundll32 InetCpl.cpl,ClearMyTracksByProcess 2

rem ������������?
@Rundll32 InetCpl.cpl,ClearMyTracksByProcess 1

rem ���������?�?���
@Rundll32 InetCpl.cpl,ClearMyTracksByProcess 8

rem ����������������
@Rundll32 InetCpl.cpl,ClearMyTracksByProcess 32

rem �������������
@Rundll32 InetCpl.cpl,ClearMyTracksByProcess 16

rem �������������?
@Rundll32 InetCpl.cpl,ClearMyTracksByProcess 255

echo	���?��� �� ActiveX ��� �� ������....
ping 127.0.0.1 -n 6 >nul 2>nul
set bl=1
:setreg
if "%bl%"=="4" goto ex

set regpath=HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\%bl%
cls
echo.
echo   ���?��� ZONE%bl% ������...
:���á�activeX�?�����JAVEС����?������?�?���

:������?��� ActiveX �?�
@reg add "%regpath%" /v "1001" /d "0" /t REG_DWORD /f
:������� ActiveX �?�
@reg add "%regpath%" /v "1004" /d "0" /t REG_DWORD /f
:���� ActiveX �?��?��
@reg add "%regpath%" /v "1200" /d "0" /t REG_DWORD /f
:��?��?�?�??���� ActiveX �?��������??�����
@reg add "%regpath%" /v "1201" /d "0" /t REG_DWORD /f
:���� Internet Explorer Web ������?��??���д
@reg add "%regpath%" /v "1206" /d "0" /t REG_DWORD /f
:������?�?� ActiveX �?���?����?�����������
@reg add "%regpath%" /v "1207" /d "0" /t REG_DWORD /f
:����������?δ?�?�ActiveX�?�������?(3�����á�0������)
@reg add "%regpath%" /v "1208" /d "0" /t REG_DWORD /f
:����?�����
@reg add "%regpath%" /v "1209" /d "0" /t REG_DWORD /f
:ActiveX �?��?��������??�?������ActiveX ����
@reg add "%regpath%" /v "120A" /d "0" /t REG_DWORD /f
:����??�?������ActiveX ����(0���� 3����)
@reg add "%regpath%" /v "120B" /d "0" /t REG_DWORD /f
:�?�?���д 
@reg add "%regpath%" /v "1400" /d "0" /t REG_DWORD /f
:Java С����?���д
@reg add "%regpath%" /v "1402" /d "0" /t REG_DWORD /f
:�?��?�?�??���� ActiveX �?�?��
@reg add "%regpath%" /v "1405" /d "0" /t REG_DWORD /f
:XSS??(3�����á�0������)
@reg add "%regpath%" /v "1409" /d "3" /t REG_DWORD /f
:��?�������
@reg add "%regpath%" /v "1609" /d "0" /t REG_DWORD /f
:�� IFRAME ������������?�
@reg add "%regpath%" /v "1804" /d "0" /t REG_DWORD /f
:?�?���������?����
@reg add "%regpath%" /v "1809" /d "3" /t REG_DWORD /f
:�����???���?
@reg add "%regpath%" /v "2000" /d "0" /t REG_DWORD /f
:����� Authenticode ?�������
@reg add "%regpath%" /v "2100" /d "3" /t REG_DWORD /f
:ActiveX �?��?���?
@reg add "%regpath%" /v "2201" /d "0" /t REG_DWORD /f
:������??�?����?�������?���
@reg add "%regpath%" /v "2300" /d "0" /t REG_DWORD /f
:?�?�����???��
@reg add "%regpath%" /v "2301" /d "3" /t REG_DWORD /f
:����ActiveX??(3�����á�0������)
@reg add "%regpath%" /v "2702" /d "0" /t REG_DWORD /f

set /a bl=%bl%+1
goto setreg

:ex

:������?��� ActiveX �?�
@reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3" /v "1001" /d "1" /t REG_DWORD /f
:������� ActiveX �?�
@reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3" /v "1004" /d "1" /t REG_DWORD /f
:��?��?�?�??���� ActiveX �?��������??�����
@reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3" /v "1201" /d "1" /t REG_DWORD /f
:�� IFRAME ������������?�
@reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3" /v "1804" /d "1" /t REG_DWORD /f

:?��?? ActiveX �?�����
REG add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\2" /v "1809" /t reg_dword /d 0x00000003 /f
REG add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3" /v "1809" /t reg_dword /d 0x00000003 /f
REG add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3" /v "1409" /t reg_dword /d 0x00000003 /f
REG add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\3" /v "2301" /t reg_dword /d 0x00000003 /f


echo	���?��� �� IE���� �� ������...

rem ?�??�IE�����
taskkill /f /im iexplore.exe

rem �������?�?����
reg add "HKCU\Software\Microsoft\Internet Explorer\New Windows" /v "PopupMgr" /t REG_SZ /d "no" /f

rem ��?����?�?�?
reg add "HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main" /v "Start Page" /t reg_sz /d "http://sso.hq.cpic.com" /f 

rem ���??���?�
reg add "HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Safety\ActiveXFiltering" /v "IsEnabled" /t REG_DWORD /d "0" /f 


echo	���?��� �� ����?�� �� ������...
rem ����??����
reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains\cpic.com\finebi.cxhae" /v http /t REG_DWORD /d 2 /f
reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains\cpic.com\hlj.cxhae" /v http /t REG_DWORD /d 2 /f

reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range1" /v "http" /t REG_DWORD  /d 00000002 /f
reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range1" /v :Range /t REG_SZ /d 10.*.*.* /f
reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range2" /v "http" /t REG_DWORD  /d 00000002 /f
reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range2" /v :Range /t REG_SZ /d 10.13.0.66 /f
reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range3" /v "http" /t REG_DWORD  /d 00000002 /f
reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range3" /v :Range /t REG_SZ /d 10.190.48.212 /f
rem ���?���??����
reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range4" /v "http" /t REG_DWORD  /d 00000002 /f
reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range4" /v :Range /t REG_SZ /d 10.190.48.23 /f
reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range5" /v "http" /t REG_DWORD  /d 00000002 /f
reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range5" /v :Range /t REG_SZ /d 10.190.50.177 /f
reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range6" /v "http" /t REG_DWORD  /d 00000002 /f
reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range6" /v :Range /t REG_SZ /d 10.190.50.178 /f

rem ?��??����
reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range7" /v "http" /t REG_DWORD  /d 00000002 /f
reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range7" /v :Range /t REG_SZ /d 10.180.143.79 /f
reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range8" /v "http" /t REG_DWORD  /d 00000002 /f
reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range8" /v :Range /t REG_SZ /d 10.180.143.204 /f
reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range9" /v "http" /t REG_DWORD  /d 00000002 /f
reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range9" /v :Range /t REG_SZ /d 10.180.143.58 /f
reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range10" /v "http" /t REG_DWORD  /d 00000002 /f
reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range10" /v :Range /t REG_SZ /d 10.180.135.204 /f
reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range11" /v "http" /t REG_DWORD  /d 00000002 /f
reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range11" /v :Range /t REG_SZ /d 10.180.135.58 /f
reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range12" /v "http" /t REG_DWORD  /d 00000002 /f
reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range12" /v :Range /t REG_SZ /d 10.180.135.79 /f
rem ?��??����
reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range13" /v "http" /t REG_DWORD  /d 00000002 /f
reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range13" /v :Range /t REG_SZ /d 10.190.53.240 /f
reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range14" /v "http" /t REG_DWORD  /d 00000002 /f
reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range14" /v :Range /t REG_SZ /d 10.190.50.13 /f
reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range15" /v "http" /t REG_DWORD  /d 00000002 /f
reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range15" /v :Range /t REG_SZ /d 10.190.50.43 /f

reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range17" /v "http" /t REG_DWORD  /d 00000002 /f
reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range17" /v :Range /t REG_SZ /d 10.190.53.240 /f
reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range18" /v "http" /t REG_DWORD  /d 00000002 /f
reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range18" /v :Range /t REG_SZ /d 10.190.53.240 /f

rem �������??����
reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range19" /v "http" /t REG_DWORD  /d 00000002 /f
reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range19" /v :Range /t REG_SZ /d 10.13.46.201 /f
reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range20" /v "http" /t REG_DWORD  /d 00000002 /f
reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range20" /v :Range /t REG_SZ /d 10.13.46.202 /f
reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range21" /v "http" /t REG_DWORD  /d 00000002 /f
reg add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Ranges\Range21" /v :Range /t REG_SZ /d 10.13.46.203 /f

echo	���?��� �� IE���� �� ������...
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 1 /f
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer /d "10.13.46.101:8080" /f
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyOverride /t REG_SZ /d "10.*;11.*;172.16.13.*;29.*;25.*;26.*;21.*;*exy.cpic.com.cn;*pxb.cpic.com.cn;*.oa.net;*.cpic.com;*.cxcq.cpic.com.cn;developer.cpic.com.cn;dcms.tb.com.cn;university.cpic.com.cn;cpicmail.cpic.com.cn;<local>" /f
rem ?��DNS����
ipconfig /flushdns

rem SSL3.0 TLS1.0 TLS1.1 TLS1.2��?
reg add "HKCUSoftwareMicrosoftWindowsCurrentVersionInternet Settings" /v SecureProtocols /t REG_DWORD /d 2720 /f

echo	���?��� �� ��������? �� ������...
set k=411f00005308adba1b00000078040000010000001b0000000c00000077116ea7a721d501010000000d00310030002e003100380030002e003100330035002e00370039000c000000ba39b8a9a721d501010000000e00310030002e003100380030002e003100330035002e003200300034000c00000078131edaa721d501010000000d00310030002e003100390030002e00350033002e003200340030000c00000056c74cdca721d501010000000c00310030002e003100390030002e00350030002e00310033000c00000084b90cdea721d501010000000c00310030002e003100390030002e00350030002e00340033000c00000082fb6fa6a821d501010000000c00310030002e003100390030002e00340038002e00320038000c000000d3a9ffafa821d50101000000080063007000690063002e0063006f006d000c0000002f52bcb9a821d501010000000d00310030002e003100390030002e003100370033002e00310032000c000000396f9cc0a821d501010000000c00310030002e003100390030002e00340038002e00330030000c000000ad144ec6a821d501010000000d00310030002e003100390030002e00340038002e003100360033000c0000003411decda821d501010000000d00310030002e003100390030002e00340038002e003100350037000c0000004c6c43d4a821d501010000000b00310030002e003100390030002e00340038002e0038000c0000005345f6daa821d501010000000b00310030002e003100390030002e00340038002e0032000c0000002de162e6a821d501010000000d00310030002e003100390030002e00340038002e003100330031000c000000b695c1efa821d501010000000d00310030002e003100390030002e00340038002e003100350030000c000000352a2451a921d501010000000b00310030002e003100390037002e0031002e00330036000c0000009570bd61a921d501010000000b00310030002e003100390037002e0031002e00360030000c0000005a274868a921d501010000000c00310030002e003100390031002e00340038002e00350036000c0000007ef56d75a921d501010000000c00310030002e003100380033002e00380035002e00340035000c000000b70b968ea921d501010000000c00310030002e003100390031002e00340038002e00310038000c000000d4980c9aa921d501010000000b0063007000690063002e0063006f006d002e0063006e000c0000002adb72aea921d501010000000a00310030002e00310033002e0030002e00360036000c000000336963943a8ed501010000000d00310030002e003100390030002e00330034002e003100300032000c00000040edc1963a8ed501010000000c00310030002e003100380033002e00310038002e00310031000c000000338cdd983a8ed501010000000d00310030002e003100390030002e00340038002e003200310032000c000000b30dd69b3a8ed501010000000d00310030002e003100380030002e003100360036002e00330039000c000000817ecbf37964d601010000000a00310030002e00310033002e00310033002e003600
@reg delete "HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\BrowserEmulation\ClearableListData" /f

rem �?�������?����?Intranet?��
@reg add "HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\BrowserEmulation" /v "IntranetCompatibilityMode" /d "0" /t REG_DWORD /f
rem ?��Microsoft�������б�
@reg add "HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\BrowserEmulation" /v "MSCompatibilityMode" /d "0" /t REG_DWORD /f
rem ����?���������?���?���
@reg add "HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\BrowserEmulation\ClearableListData" /v "UserFilter" /d "%k%" /t REG_BINARY /f

echo	���?��� �� ����IE���� �� ������...
del /f /s /q "%userprofile%\AppData\Local\Microsoft\Windows\Temporary Internet Files\*.*"

echo	���?��� �� ����??���� �� ������...
del /f /s /q "%temp%\*.*"

echo �����?��?�?������ ����?����
netsh advfirewall firewall set rule group="�?��?�?������" new enable=yes

echo   ������?����IE����?���?���������������������?�����IE�?�����?���
echo   �������?��?��?�...
ping 127.0.0.1 -n 10 >nul 2>nul
exit

ipconfig_set.bat

@echo off
netsh interface ip set address "��?��" static 10.13.1.92 255.255.255.0 10.13.1.254
netsh interface ip set dns "��?��"  static 10.183.16.200 validate=no
netsh interface ip add dns "��?��" 10.193.16.105 validate=no
ipconfig /flushdns
pause
exit

ipdnsset.bat

@echo off
:start
echo 1����������?IP��
echo 2������������?IP��
set /P var="��������?��?��?������:"
if %var%==1 goto ip1
if %var%==2 goto ip2
:ip1
cls
netsh interface ip set address "��?��" static 10.13.1.92 255.255.255.0 10.13.1.254
netsh interface ip set dns "��?��"  static 10.183.16.200 validate=no
netsh interface ip add dns "��?��" 10.193.16.105 validate=no
ipconfig /flushdns
echo ** �������?IP **
echo ------------------------------------------
pause
exit
goto start
:ip2
cls
netsh interface ip set address "��?��" dhcp
netsh interface ip set dns "��?��" dhcp
ipconfig /flushdns
echo ** ���������?IP **
echo ------------------------------------------
pause
exit

restart_print_service.bat

@echo off
echo ??��?����
net stop Spooler
echo ����������?����
net start Spooler
echo ���!!!!
pause
exit

update_strategy.bat

@echo off
Echo ���2���...
gpupdate /force
gpresult /r
echo ���2������...

  Python知识库 最新文章
Python中String模块
【Python】 14-CVS文件操作
python的panda库读写文件
使用Nordic的nrf52840实现蓝牙DFU过程
【Python学习记录】numpy数组用法整理
Python学习笔记
python字符串和列表
python如何从txt文件中解析出有效的数据
Python编程从入门到实践自学/3.1-3.2
python变量
上一篇文章      下一篇文章      查看所有文章
加:2022-09-04 01:07:23  更:2022-09-04 01:08:29 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年12日历 -2024/12/26 15:38:37-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码
数据统计