# -*- coding: utf-8 -*-
import webbrowser,os,time
base_path = 'F:\webapps' #重启日志信息文件的路径
log_file = base_path + '\%s.log' %(time.strftime('%Y%m%d',time.localtime()))
now = int(time.time())
timeArray = time.localtime(now)
otherStyleTime = time.strftime("%Y-%m-%d %H:%M:%S", timeArray)
def chongqi():
try:
detection = len(os.popen('tasklist /FI "IMAGENAME eq iexplore.exe"').read().decode('cp936'))
if detection > 19: #检测ie进程是否存在,存在则杀掉,不存在则直接打开html文件
os.system('taskkill /F /IM iexplore.exe') #把ie浏览器杀掉
webbrowser.open_new('F:\\webapps\\haha\\iexplore1.lnk')
webbrowser.open_new('F:\\webapps\\haha\\iexplore2.lnk') #重启每个html文件,这里将html文件都做成快捷方式更方便
webbrowser.open_new('F:\\webapps\\haha\\iexplore3.lnk')
webbrowser.open_new('F:\\webapps\\haha\\iexplore4.lnk')
os.system("echo %s browser restart,url open succesfully! >> %s" %(otherStyleTime, log_file))
else:
webbrowser.open_new('C:\inetpub\wwwroot\iexplore1.lnk')
webbrowser.open_new('C:\inetpub\wwwroot\iexplore2.lnk')
webbrowser.open_new('C:\inetpub\wwwroot\iexplore3.lnk')
webbrowser.open_new('C:\inetpub\wwwroot\iexplore4.lnk')
os.system("echo %s browser do not restart,url open successfully! >> %s" %(otherStyleTime, log_file))
except:
os.system("echo %s restart url failed! >> %s" %(otherStyleTime, log_file))
if __name__ == '__main__':
chongqi()
import webbrowser,os,time
base_path = 'F:\webapps' #重启日志信息文件的路径
log_file = base_path + '\%s.log' %(time.strftime('%Y%m%d',time.localtime()))
now = int(time.time())
timeArray = time.localtime(now)
otherStyleTime = time.strftime("%Y-%m-%d %H:%M:%S", timeArray)
def chongqi():
try:
detection = len(os.popen('tasklist /FI "IMAGENAME eq iexplore.exe"').read().decode('cp936'))
if detection > 19: #检测ie进程是否存在,存在则杀掉,不存在则直接打开html文件
os.system('taskkill /F /IM iexplore.exe') #把ie浏览器杀掉
webbrowser.open_new('F:\\webapps\\haha\\iexplore1.lnk')
webbrowser.open_new('F:\\webapps\\haha\\iexplore2.lnk') #重启每个html文件,这里将html文件都做成快捷方式更方便
webbrowser.open_new('F:\\webapps\\haha\\iexplore3.lnk')
webbrowser.open_new('F:\\webapps\\haha\\iexplore4.lnk')
os.system("echo %s browser restart,url open succesfully! >> %s" %(otherStyleTime, log_file))
else:
webbrowser.open_new('C:\inetpub\wwwroot\iexplore1.lnk')
webbrowser.open_new('C:\inetpub\wwwroot\iexplore2.lnk')
webbrowser.open_new('C:\inetpub\wwwroot\iexplore3.lnk')
webbrowser.open_new('C:\inetpub\wwwroot\iexplore4.lnk')
os.system("echo %s browser do not restart,url open successfully! >> %s" %(otherStyleTime, log_file))
except:
os.system("echo %s restart url failed! >> %s" %(otherStyleTime, log_file))
if __name__ == '__main__':
chongqi()
本文介绍了一个用于自动重启Internet Explorer浏览器并打开特定网页链接的Python脚本。该脚本首先检查IE是否正在运行,如果运行则先终止IE进程,然后通过快捷方式启动四个不同的HTML页面,并记录操作日志。
1308

被折叠的 条评论
为什么被折叠?



