Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Locating Desktop element

Status
Not open for further replies.

TimRHSD

Programmer
Apr 18, 2002
35
0
0
US
Hi,

I want to put a file on a user's desktop, but I can't seem to find how to access that environment element. Seem to recall seeing a post in this group about it, but can't find it. Any help would be appreciated.

Thanks,

Tim

Tim Rutherford
 
Check this:
thread329-763238

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
You can access all special folders by using the Shell.Application object:
CONST DESKTOP = &H10&
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(DESKTOP)
Set objFolderItem = objFolder.Self
strPath = objFolderItem.Name

-OR-

Set objShell = CreateObject("WScript.Shell")
strDesktopFolder = objShell.SpecialFolders("Desktop")
(Which is obviously easier and quicker).

This script will not provide the desired results if run in an alternate security context - in other words, if you run this script through SMS using admin rights instead of user rights, the file will not be placed on the right desktop. If you want something to show on all user's desktops, then just use c:\documents and settings\all users\desktop.

I would also recommend you get a copy of "Microsoft Windows 2000 Scripting Guide - Automating System Administration" - that information and much more is in there.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top