【发布时间】:2021-08-12 22:17:23
【问题描述】:
我正在使用一个 NodeJs 应用程序,它在内部调用 process.arch 来获取系统架构,然后根据结果构建路径,例如。 - path/to/file/x64/file(应用是 selenium-standalone NPM 包)。
现在我需要在 PowerShell 脚本中构建相同的路径,因此我还需要获取系统架构。但是用 f.ex 来做这件事。 (Get-WmiObject Win32_Processor).AddressWidth 返回没有 x 的结果 - 只是 64 所以我的路径最终是 path/to/file/64/file 这是错误的。我目前的解决方法是显式添加x:
$arch = (Get-WmiObject Win32_Processor).AddressWidth
if ($arch -eq 32) { $arch = 'x32' }
if ($arch -eq 64) { $arch = 'x64' }
您认为这样做安全吗?或者有没有办法从 powerShell 获得它已经分配了x?
【问题讨论】:
-
这当然不安全,因为 1) 它假设只有 1 个
Win32_Process实例存在,并且 2) 它只评估 platform 架构,而不是流程架构。
标签: node.js powershell architecture