1

操作系统用户名为中文时,使用 nodejs 的 exec 命令执行指令失败

 2 years ago
source link: https://www.v2ex.com/t/809950
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

V2EX  ›  Node.js

操作系统用户名为中文时,使用 nodejs 的 exec 命令执行指令失败

  yocoso · 22 小时 27 分钟前 · 1001 次点击

开发的软件遇到个问题,请教一下如何解决?

通过 nodejs 执行命令,需要执行的程序 compress.exe 是在用户文件夹下,而用户名是中文,这时候会报错,说 the system cannot find the path specified

请问有何办法绕过这个中文用户吗?

实验过,只有系统用户名是中文会报错,如果是文件名中文并不会报错。

C:\Users\虎鲸>node test.js
Error: Command failed: C:\Users\虎鲸\AppData\Local\Studio\app-1.0.3\resources\app\ext\fbximporter\fbx2cal3d.exe --log C:\Users\虎鲸\Documents\IMVU Studio Projects\_fbx\_logs\THE_tshirt_Square.fbx.data.txt -f C:\Users\虎鲸\Documents\Studio Projects/_fbx/current.fbx --list-all
The system cannot find the path specified.
    at ChildProcess.exithandler (child_process.js:383:12)
    at ChildProcess.emit (events.js:400:28)
    at maybeClose (internal/child_process.js:1058:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:293:5) {
  killed: false,
  code: 1,
  signal: null,
  cmd: 'C:\\Users\\虎鲸\\AppData\\Local\\Studio\\app-1.0.3\\resources\\app\\ext\\fbximporter\\fbx2cal3d.exe --log C:\\Users\\虎鲸\\Documents\\Studio Projects\\_fbx\\_logs\\THE_tshirt_Square.fbx.data.txt -f C:\\Users\\虎鲸\\Documents\\Studio Projects/_fbx/current.fbx --list-all'
}

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK