diff --git a/assets/code_run_header.py b/assets/code_run_header.py index 59fb3416..7ba351ed 100644 --- a/assets/code_run_header.py +++ b/assets/code_run_header.py @@ -7,6 +7,7 @@ def _d(b): try: return b.decode() except: return b.decode('gbk', 'replace') def _run(*a, **k): + if os.name == 'nt': k['creationflags'] = (k.get('creationflags') or 0) | 0x08000000 t = k.pop('text', 0) | k.pop('universal_newlines', 0) enc = k.pop('encoding', None) k.pop('errors', None) diff --git a/ga.py b/ga.py index 39fddb22..688dd179 100644 --- a/ga.py +++ b/ga.py @@ -26,7 +26,8 @@ def code_run(code, code_type="python", timeout=60, cwd=None, code_cwd=None, stop tmp_file.close() cmd = [sys.executable, "-X", "utf8", "-u", tmp_path] elif code_type in ["powershell", "bash", "sh", "shell", "ps1", "pwsh"]: - if os.name == 'nt': cmd = ["powershell", "-NoProfile", "-NonInteractive", "-Command", code] + if os.name == 'nt': + cmd = ["powershell", "-NoProfile", "-NonInteractive", "-ExecutionPolicy", "Bypass", "-Command", code] else: cmd = ["bash", "-c", code] else: return {"status": "error", "msg": f"不支持的类型: {code_type}"}