1

I feel like this should be simple but I searched for a good half hour and couldn't find it.

Basically I have an Adobe PDF file that runs a snippet of JavaScript to verify input and, if it deems the input ok, save the PDF to the desktop. This works fine when I hard code in the desktop, ex.:

var mypath = "/c/users/someusernamehere/desktop/";

However, we are trying to deploy this to many machines here, I do not want to have to hard code in everyone's desktop path.

Is there a way for JavaScript to get the desktop path of the current user?

PS. All of our machines use Windows 7.

/EDIT To clarify, this is not an Internet thing, it is all local. Just a PDF that is already stored on the user's machine accessing a JavaScript file stored in the same directory. That directory is:

C:\Program Files (x86)\Adobe\Reader 11.0\Reader\Javascripts

Andrew Whatever
  • 396
  • 4
  • 15
  • Have you read http://forums.asp.net/t/1086750.aspx?How+to+Determine+Desktop+path+Of+Client+Machine+in+javascript ? – Yuck Oct 22 '14 at 17:18
  • Depends, are you trying to do it from the user's browser? If so, no. – George Stocker Oct 22 '14 at 17:26
  • It's not from a browser, it is from a PDF file stored in a folder under program files 86 / adobe / etc. This accesses a JavaScript file in the same folder. Completely local, not related to online anything! – Andrew Whatever Oct 22 '14 at 17:28
  • What PDF file is this? Did your company create it? If so, how? If I understood correctly, it will all depend on how the PDF is running JS – btx9000 Oct 22 '14 at 17:35
  • Yeah my company created it in Adobe Acrobat. I don't know exactly what they did but I was informed it was some kind of way to attach JavaScript to a button. Why would it matter how it was created? – Andrew Whatever Oct 22 '14 at 17:52

1 Answers1

1
var objWSHShell = new ActiveXObject("WScript.Shell");
var strDesktopPath = objWSHShell.SpecialFolders("Desktop");
Servy
  • 202,030
  • 26
  • 332
  • 449
AShatov
  • 11
  • 1