MCPcopy Create free account
hub / github.com/WavesMan/Disable-automatic-Windows-update / disable

Method disable

python/core/services.py:399–423  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

397 return (len(errors) == 0), errors
398
399 def disable(self) -> Result:
400 start = time.perf_counter()
401 log_event(logging.INFO, "firewall_disable_started", "开始停用防火墙", action="disable_firewall", status="started")
402 cmds = [
403 "netsh advfirewall set allprofiles state off",
404 "netsh advfirewall set domainprofile state off",
405 "netsh advfirewall set privateprofile state off",
406 "netsh advfirewall set publicprofile state off",
407 ]
408 ok, errors = self._batch(cmds)
409 duration_ms = int((time.perf_counter() - start) * 1000)
410 if ok:
411 log_event(logging.INFO, "firewall_disable_finished", "停用防火墙成功", action="disable_firewall", status="ok", duration_ms=duration_ms)
412 return Result(True, data={"status": "firewall_disabled"})
413 log_event(
414 logging.ERROR,
415 "firewall_disable_finished",
416 "停用防火墙失败",
417 action="disable_firewall",
418 status="failed",
419 duration_ms=duration_ms,
420 error_type="FIREWALL_DISABLE_FAILED",
421 error_message="; ".join(errors),
422 )
423 return Result(False, error={"code": "FIREWALL_DISABLE_FAILED", "message": "防火墙停用失败", "details": errors})
424
425 def enable(self) -> Result:
426 start = time.perf_counter()

Callers

nothing calls this directly

Calls 3

_batchMethod · 0.95
log_eventFunction · 0.85
ResultClass · 0.85

Tested by

no test coverage detected