Skip to content
This repository has been archived by the owner on Mar 6, 2021. It is now read-only.

Commit

Permalink
Update Waifu2x-Extension-Start.py
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronFeng753 committed Sep 25, 2019
1 parent 7cf9b7b commit 7e6a890
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions Waifu2x-Extension-Start.py
Expand Up @@ -2,6 +2,7 @@
import time
import psutil
import json
import ctypes

def judgeprocess(processname):
pl = psutil.pids()
Expand All @@ -11,6 +12,24 @@ def judgeprocess(processname):
break
else:
return True

def AdminTest():
current_dir = os.path.dirname(os.path.abspath(__file__))
tmp_dir = current_dir+'\\'+'admintest.tmp'
if os.path.exists(tmp_dir) == False:
try:
with open(tmp_dir,'w+') as f:
f.write('admintest')
except BaseException:
return False
if os.path.exists(tmp_dir) == False:
return False
else:
os.system('del /q "'+tmp_dir+'"')
return True
else:
os.system('del /q "'+tmp_dir+'"')
return True

def Read_config():
config_path = 'Waifu2x-Extension\\config_waifu2xEX_start'
Expand Down Expand Up @@ -53,6 +72,24 @@ def Read_config():
os.system('mode con cols=35 lines=15')
os.system('color f0')
os.system('title = Waifu2x-Extension')

if AdminTest() == False:
os.system('mode con cols=120 lines=20')
os.system('cls')
print('-------------------------------------------------------------------')
print('我们检测到当前软件所处的文件夹导致软件必须申请\n 管理员权限来继续正常运行.')
print('我们建议您将软件移动到另一个文件夹或者直接给予软件管理员权限')
print('')
print('We have detected that the current directory of the software is causing the software to apply for administrator\n privileges to continue normal operation.')
print('We recommend that you move the software to another directory or give software administrator privileges.')
print('--------------------------------------------------------------------')
print('按Enter键来重启软件并申请管理员权限. ')
print('')
print('Press Enter key to Re-run the program with admin rights. ')
input()
# Re-run the program with admin rights
ctypes.windll.shell32.ShellExecuteW(None, "runas", sys.executable, __file__, None, 1)

language = Read_config()
os.system('cls')
print(' =============')
Expand Down

0 comments on commit 7e6a890

Please sign in to comment.