Has anyone managed to use either of these functions successfully
<html>
<head>
<script language="javascript">
</head>
<body style="width:100px; height:100px; margin:0px;"></body>
</html><script language="javascript">
try{
var p = System.Shell.knownFolderPath("My Documents");
} catch(err) {System.Debug.outputString(err.name+" - "+err.message)}
</script>var p = System.Shell.knownFolderPath("My Documents");
} catch(err) {System.Debug.outputString(err.name+" - "+err.message)}
</head>
<body style="width:100px; height:100px; margin:0px;"></body>

System.Shell.knownFolder/knownFolderPath - do they work?
SonAsylum
knownFolder specifies "Takes a string that represents a user's well-known folder, such as My Documents, and returns an instance of a System.Shell.Folder object based on that folder path." and yet the parameters are listed as:
Which makes me believe it needs a System.Shell.Folder object and not a string as a parameter.
knownFolderPath's parameter is listed as:
So, what is the parameter A string or a System.Shell.Folder object Perhaps someone from MS can get the documentation corrected and provide a working example.
Jamie Thomson
Perhaps MS can verify this for us.
QWERTYtech
The doc parameter looks wrong, it should be a string name, but the known folder variable you're using of "My Docuements" is the real source of the (very unfortunate) "Automation server..." error.
I can't find the list of Known Folders for Vista right now, but the one you're looking for is "documents". That will return a path in my quick test.
System.Shell.knownFolderPath("documents");
Brian
AlanKohl
You just need to get it put up on MSDN now, as those docs are completely misleading!
Canada Goose
I've been trying to use (in javascript within a gadget) System.Shell.knownFolder, System.Shell.knownFolderPath, and System.Shell.itemFromPath to get a hold of the value of "RecycleBinPath". I've noticed that this always causes a javascript exception, with the lovely message "Object error". Now, if I used a bad path, like "RecyclceBinFolder", I get the automaton error I expect due to a malformed path, so that's not what's going on.
I can use all of the above methods to get OTHER folders, but I cannot get a reference to the RecyleBin in this way. Additionally, I even tried hardcoding the path "C:\$Recycle.Bin" into a itemFromPath and, ta-da, same object error!
This *implies* to me (read: probably wrong) that the javascript language bindings for recycle bin objects are somehow broken, and simply explode whenever they would otherwise succeed. I mean, I can't even get the string path back with this, but I can use it for known folders like "documents" (which works fine). Am I missing something Any thoughts
Bernaridho
god_of_coolness
Andy
AliciaV
Thank you for the suggestions. Unfortunately, I don't know what knownFolder returns - it explodes during the call itself, it never makes it as far as actually returning. It wouldn't shock me.
As far as browsing for it on the desktop, I think that this would probably just get to the same problem via a different route. Plus, not everyone has the Recycle Bin on their desktop: it is optional (I have mine turned off, for example). A good idea and thank you for the response, but I'm afraid its not viable.
My guess is that the Recycle Bin is a "magic" folder. As in, you can't get its contents, you can't navigate through it, and you can't directly touch anything inside it (thus the existence of System.Shell.RecycleBin); unfortunately, this makes it nigh-impossible to do some things correctly (for example: figure out how much space is actually free on a drive. The "used space" includes the recycle bin; but you can't get a tally of just one drive's recycle bin contents, so you can't tell how much of the drive is REALLY free unless you go count up the size of every single file - not a pleasant prospect).
Greg Christensen
Sorry for the bad docs. Here's the list of strings that the knownFolder/knownFolderPath APIs will accept:
Desktop
Startup
StartMenu
Documents
Programs
CommonStartup
CommonPrograms
PublicDesktop
PublicFavorites
PublicDocuments
System
SystemX86
Profile
Windows
Pictures
Music
Videos
ProgramFiles
ProgramFilesCommon
ProgramFilesX86
ProgramFilesCommonX86
AdminTools
CommonAdminTools
PublicMusic
PublicPictures
PublicVideos
UserProfiles
Downloads
PublicDownloads
GadgetsUser
RecycleBinFolder
Harrynet
Vladimir Bougay
System.Shell.execute("explorer.exe", "desktop");
System.Shell.execute("explorer.exe", "documents");
System.Shell.execute("explorer.exe", "pictures");
System.Shell.execute("explorer.exe", "c:\my folder");
Johnny Raved
Okay, I have a question that might be related to this topic...
I am using the code below in a gadget that simply links to My Docs. The problem I am facing is that I have only been able to link the gadget to My Docs, Network Connections, and Recycle Bin. Those are the only folders I could find the string paths too... Is there an alternative to using var Path= "::{string}"; I would imagine System.Shell.knownFolder would work if I knew where to put it in the code. (I am a newb to gadgets) I would really like to link to My Music, My Pictures, My Videos, E:\Downloads or any folder I want. I hope someone understands what I am trying to do here, and hope someone can help me out a little. If this isnt the right place to ask this question, I apologize sincerely!