You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

执行netsh int ip reset时部分项权限拒绝的问题排查求助

执行netsh int ip reset时部分项权限拒绝的问题排查求助

各位大佬好,我最近遇到个棘手的问题,想请大家帮忙分析下:

我写了一段重置网络适配器的TypeScript代码,如下:

public resetNetworkAdapter(): void {
  // windows reported everything is OK for most of adapters,
  // but then winked and asked for some god-mode rights for others
  // (slight reminder that application is running under admin by default).
  // who am I to argue with our machine overlords?
  try {
    execSync('netsh int ip reset')
  } catch {
    console.log('do nothing here...')
  }
  execSync('netsh winsock reset')
}

我试着在应用环境里运行这段脚本,也单独在终端里执行了netsh int ip reset命令——明明我的应用默认就是以管理员权限运行的,但执行命令时大部分项都显示“OK”,却偏偏有一项提示“Reset - Failed. Access Denied.”,完整的终端输出是这样的:

Reset Forwarding Sections - OK!
Reset Section - OK!
Reset Control Protocol - OK!
Reset Echo Request Sequence - OK!
Reset Global - OK!
Reset Interface - OK!
Reset Anycast Address - OK!
Reset Multicast Address - OK!
Reset Unicast Address - OK!
Reset Neighbor - OK!
Reset Path - OK!
Reset Potential - OK!
Reset Prefix Policy - OK!
Reset Proxy Neighbor - OK!
Reset Route - OK!
Reset Site Prefix - OK!
Reset Subordinate Interface - OK!
Reset Wake Pattern - OK!
Reset Allow Neighbor - OK!
Reset - OK!
Reset - OK!
Reset - OK!
Reset - OK!
Reset - Failed. Access Denied.
Reset - OK!
Reset - OK!
Reset - OK!
Reset - OK!
Reset - OK!
Reset - OK!
Reset - OK!
Reset - OK!
A system reboot is required to complete this operation.

执行完命令后,$LASTEXITCODE === 1,$? === False,说明命令确实没有完全执行成功。

我实在搞不明白这是咋回事,总不能一直留着代码里那段吐槽的注释吧?有没有大佬能帮我理清到底哪里出问题了,该怎么解决?

内容来源于stack exchange

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.07 13:24:31