Shoutbox

How to obtain the Desktop path - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: How to obtain the Desktop path (/showthread.php?tid=76641)

How to obtain the Desktop path by johny65 on 08-08-2007 at 11:27 PM

Hi!
I would like to know how to get the Desktop path with a script, and also other paths, like Windows folder or System folder.
Thanks!


RE: How to obtain the Desktop path by mondator on 08-08-2007 at 11:38 PM

use the global windows var like %USERPROFILE%\ the full path of the current windows user folder its very useful u can acces desktop or my documents exemple:   %USERPROFILE%\Desktop to get the desktop path but this work only to give it to a function ho interact with path like sendfile if u want the path in a var in your script see the solution below:)


RE: How to obtain the Desktop path by markee on 08-08-2007 at 11:40 PM

You can get some special folders using the following code.

code:
var WSH = new ActiveXObject("WScript.Shell");
var folder = WSH.SpecialFolders(folderLookup);

folderLookup is a string and can be any of the following:
  • AllUsersDesktop
  • AllUsersStartMenu
  • AllUsersPrograms
  • AllUsersStartup
  • Desktop
  • Favorites
  • Fonts
  • MyDocuments
  • NetHood
  • PrintHood
  • Programs
  • Recent
  • SendTo
  • StartMenu
  • Startup
  • Templates
I think the reason for not allowing access to the likes of the system folder is primarily for security reasons.
RE: How to obtain the Desktop path by -dt- on 08-09-2007 at 02:38 AM

you can also use this, and then you get access to everything listed here
http://msdn2.microsoft.com/en-us/library/ms649274.aspx

code:
function getSpecialDir( CSIDL){
    var szSendToPath = Interop.Allocate((255 *2) +2);
    Interop.Call("Shell32", "SHGetSpecialFolderPathW", 0, szSendToPath,  CSIDL, 0);
    return szSendToPath.ReadString(0);
}


RE: How to obtain the Desktop path by johny65 on 09-10-2007 at 01:08 AM

Thank you very much!! Especially to markee, that was just what I needed.

Saludos!