gpt4 book ai didi

javascript - 如何获取 %userprofile%\My Documents\

转载 作者:行者123 更新时间:2023-11-30 07:40:22 24 4
gpt4 key购买 nike

如果省略\My Documents\,以下函数将起作用,但我需要访问我的文档。

OpenTextFile("test.txt");

function OpenTextFile(file) {
var ObjShell = new ActiveXObject("Shell.Application");
var wShell = new ActiveXObject("WScript.Shell");
var path = wShell.ExpandEnvironmentStrings("%userprofile%\My Documents\");
ObjShell.ShellExecute("Notepad.exe", file, path, "Open", "1");
}

按原样,它给了我一个错误:未终止的字符串常量 Line 7 Char 80

最佳答案

在字符串中,\ 是转义字符。如果你想包含一个 \ 你必须转义它。

wShell.ExpandEnvironmentStrings("%userprofile%\\My Documents\\");

关于javascript - 如何获取 %userprofile%\My Documents\,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18772424/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com