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!

Desktop Shortcut via Domain Policy

Status
Not open for further replies.

QuarkIT

IS-IT--Management
Jan 11, 2005
34
0
0
US
Hey guys...I've read of several ways to impliment this via AD.

Basically after the adventure of creating a login script for the company, the Execs are starting to realize the managment capabilities I can offer...so now they want to create several company standard desktop shortcuts.

I've read that there are several options, including running a login script, or using folder redirection.

Was interested in the script personally, as I could just add it to the existing one I'm using currently...but I am open to suggestion.

Appreciate the help
 
QuarkIT,

Put the shortcuts you want to copy in the NETLOGON share and add the following line(s) to your logon script...

copy \\DCNAME\NETLOGON\Shortcut.lnk "C:\Documents and Settings\%username%\Desktop" /y

We use it all the time...

john
 
I'd recommend having one line entry per shortcut, because you should always avoid wildcards in batch files (especially login scripts) unless you have to or it makes more sense. I would also recommend doing an “if not exist” statement, that way it doesn’t automatically overwrite the shortcuts every time. It’s easy enough to force at a later date. Also, I’d use the userprofile variable instead of the username variable, because that will be the true path of your destination. If you use the DNS name of your domain, you don’t have to specify a specific domain controller either. Here’s an example:

If not exist “%userprofile%\desktop\link1.lnk” xcopy /y “\\mydomain.com\netlogon\shortcuts\link1.lnk” “%userprofile%\desktop\”
NOTE: The final “\” at the end ensures the xcopy command knows it’s a file and not a directory.

If you prefer to use a wildcard copy that copies the shortcuts every time, I’d recommend using the /d option in xcopy. That will only copy the files that have a newer date in the source.

xcopy /d “\\mydomain.com\netlogon\shortcuts\link1.lnk” “%userprofile%\desktop\”

I use batch files a lot, so if you have any questions fire away.


I hope this helps.

Thanks,

Tom
 
Okay using the first script, I am unable to get it to execute in my VB script.

I can execute it from a cmd prompt no problems.

Here is the line I have

copy "\\server4\netlogon\shortcuts\sop.lnk" "C:\documents and settings\%username%\desktop" /y


Now in VB it will execute, and then say error at char 45, which is the beginning of the second quotation. In CMD it executes fine.

Tried removing the " " on either side, no go.

As (copy \\server4\netlogon\shortcuts\sop.lnk "C:\documents and settings\%username%\desktop" /y) it says syntax error at char 6.

Let me know, and thanks for the help guys
 
Sorry guys but this is NOT the way to go about it.

You can dynamically build the shortcut in your script, no copy method is required and this will check if the icon already exists and if so do nothing.

Here is an example:
Code:
SET fso = Wscript.CreateObject("Scripting.FileSystemObject")
SET WshShell = WScript.CreateObject("WScript.Shell")
WinDir = WshShell.ExpandEnvironmentStrings("%WinDir%")
strDsk = WshShell.SpecialFolders("Desktop")
strshortcut = strDsk & "\Calculator.lnk"
If Not fso.FileExists(strshortcut) Then
	SET oUrlLink = WshShell.CreateShortcut(strshortcut)
	oUrlLink.TargetPath = Windir & "\System32\Calc.EXE"
	oUrlLink.Save
End If

Using this method you will get the default icon for your shortcut whatever that might be. You can also specify an EXE or DLL file as an icon (but not an ico) via script.

In the future, I suggest posting script questions in the vbscript forum, you will get the best scriting answers there. forum329

You may also want to refer to my FAQ on the subject of login scripts. faq329-5798

I hope you find this post helpful.

Regards,

Mark
 
Hey mark, appreciate the response and advice.

The script works partially. I set the path to the file, but it's still redirecting to the local HDD

The file itself is an excel spreadsheet located on the server.

I only posted here as I knew there were various methods of achieivng the goal, and was unsure as to which would be the easiest route.

Thanks again
 
disregard the part about the local HDD, corrected it myself...thanks again :D
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top