44import json
55import glob
66import win32crypt
7+ import ctypes
78import random
89import hashlib
910import sqlite3
@@ -58,6 +59,7 @@ def get_dpg5_config(dgp5_path):
5859argpar .add_argument ("--login-force" , action = "store_true" )
5960argpar .add_argument ("--skip-exception" , action = "store_true" )
6061argpar .add_argument ("--https-proxy-uri" , default = None )
62+ argpar .add_argument ("--non-request-admin" , action = "store_true" )
6163arg = argpar .parse_args ()
6264
6365HEADERS = {
@@ -160,7 +162,6 @@ def get_dpg5_config(dgp5_path):
160162 verify = False ,
161163 proxies = PROXY ,
162164).json ()
163- print (response )
164165if response ["result_code" ] == 100 :
165166 dmm_args = response ["data" ]["execute_args" ].split (" " )
166167 start_time = time .time ()
@@ -171,7 +172,18 @@ def get_dpg5_config(dgp5_path):
171172 text = line .decode ("utf-8" ).strip ()
172173 print (text )
173174 if time .time () - start_time < 2 and not arg .skip_exception :
174- raise Exception ("ゲームが起動しませんでした。ゲームにアップデートがある可能性があります。" )
175+ if response ["data" ]["is_administrator" ] and not arg .non_request_admin :
176+ if not ctypes .windll .shell32 .IsUserAnAdmin ():
177+ ctypes .windll .shell32 .ShellExecuteW (
178+ None , "runas" , game_path , response ["data" ]["execute_args" ], None , 1
179+ )
180+ else :
181+ raise Exception ("ゲームが起動しませんでした。管理者権限を許可してください。" )
182+ elif response ["data" ]["is_administrator" ]:
183+ raise Exception ("ゲームが起動しませんでした。管理者権限を許可してください。" )
184+ else :
185+ if not arg .skip_exception :
186+ raise Exception ("ゲームが起動しませんでした。ゲームにアップデートがある可能性があります。" )
175187elif response ["result_code" ] == 801 :
176188 if not arg .skip_exception :
177189 raise Exception ("日本国外からのアクセスは禁止されています\n " + json .dumps (response ))
0 commit comments