Thursday, 12 September 2013

How to get %userprofile%\My Documents\

How to get %userprofile%\My Documents\

The following function will work if \My Documents\ is omitted, but I need
to get to 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");
}
as is, it gives me an error: Unterminated string constant Line 7 Char 80

No comments:

Post a Comment