We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

HELP!!!  Need to add a web link to the Favorites of all my lab PCs

Medium Priority
759 Views
Last Modified: 2012-05-11
Hi, I need to create a script that will add the following link to all my student lab PCs favorites for IE on our XP Pro systems.

javascript:d=document;i='AddToRWScript';try{RWAddToRW1();}catch(e){s=d.createElement('script');s.type='text/javascript';s.src='http://www.refworks.com/refgrabit/rgibookmark.aspx?rgiid=faea0919-8ade-4097-8d89-bbc7108c45c8';s.id=i;d.getElementsByTagName('head')[0].appendChild(s);}void(0);

I cannot just add this to the GP because as you can see it is not a typical URL address.

I don't care how I accomplish it just as long as it is simple and quick, GP, VB script, PowerShell, etc.

I do have PowerShell installed on all the XP systems in the labs.  So, I guess PS could be used?

Any suggestions or script code will be greatly appreciated.

Thanks in advance.
Comment
Watch Question

CERTIFIED EXPERT
Top Expert 2010
Commented:
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview
CERTIFIED EXPERT

Commented:
Here's a script that, if run by the user, will add the favorite for them.  You can copy the script to the ALL USERS STARTUP folder
On Error Resume Next
Set objFSO = CreateObject("Scripting.FileSystemObject")

strFile = "MyFavorite.url"

Set WshShell = CreateObject("WScript.Shell")
strFavorites = WshShell.SpecialFolders("Favorites")

strURLPath = strFavorites & "\" & strFile

If objFSO.FileExists(strURLPath) Then
	'Favorite already exists for this user...quit
	WScript.Quit(0)
End If

strURL = "javascript:d=document;i='AddToRWScript';try{RWAddToRW1()" & _
  ";}catch(e){s=d.createElement('script');s.type='text/javascript';s.src=" & _
  "'http://www.refworks.com/refgrabit/rgibookmark.aspx?rgiid=faea0919-8ade-4097-8d89-bbc7108c45c8'" & _
  ";s.id=i;d.getElementsByTagName('head')[0].appendChild(s);}void(0);"

Set objShortcutUrl = WshShell.CreateShortcut(strURLPath)
objShortcutUrl.TargetPath = strURL
objShortcutUrl.Save

Open in new window

rsnellmanIT Manager

Author

Commented:
Thanks for the quick responses.  I like the different approaches.  However, how can I get it on the systems remotely?  LIke tmassa99, how could I get this on the systems remotely via a startup script or logon script via GP?  Or BlueDevilFan, how can I get this URL shortcut onto the lab PCs?
Commented:
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview
CERTIFIED EXPERT
Top Expert 2010

Commented:
koiboi86 hit the nail on the head.  That's exactly how I'd copy the file.  
CERTIFIED EXPERT

Commented:
Here's a script that if run as an admin can copy a file from one location to a list of PCs "STARTUP" folder.  Just create a file called LABPCs.txt and place it in the same location as the script when you run it.

Just edit the line with "strSourceFile" with the path of the script I wrote above.
Certainly, just try one computer in the list first.

 
On Error Resume Next
ComputerList = "LabPCs.txt"

strSourceFile = "\\server\share\filename.vbs"

Const ForReading = 1, ForWriting = 2, ForAppending = 8
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile(ComputerList, ForReading, True)

Do While f.AtEndOfLine <> True
  strComputer = f.ReadLine
  strDestination = "\\" & strComputer & "\Documents and Settings\All Users\Start Menu\Programs\Startup\"
  fso.CopyFile strSourceFile, strDestination
Loop

Open in new window

rsnellmanIT Manager

Author

Commented:
Thanks to all for all the help.  I have just one more question about this process.  Will this xcopy overwrite the existing link on the lab systems?  Reason I ask is the organization of the link has changed the link and that is why I need to push this new link out to correct that.

Thanks.
rsnellmanIT Manager

Author

Commented:
OK, I guess I am having permission issues trying to copy the .url provided by BlueDevilFan.

I would like to add the .url to either the "All Users\Favorites" or better yet copy over the existing .url in the "Default User\Favorties".

So, I created a bat file based off of koiboi86's suggestion:
--------------------------------------------------------------------------------------------
xcopy \\server\folder\file to C:\Documents and Settings\All Users\Favorites

exit
---------------------------------------------------------------------------------------------
And I tried this code too:
--------------------------------------------------------------------------------------------
xcopy \\server\folder\file to C:\Documents and Settings\Default User\Favorites

exit
---------------------------------------------------------------------------------------------

I tried these codes in the Computer Configuration\Startup Scripts & User Configuration\Logon Scripts.

That should have worked, right?  Or am I missing something in this code?  Remember I am no scripter.

CERTIFIED EXPERT

Commented:
My File copy script should have included "C$\"...

On Error Resume Next
ComputerList = "LabPCs.txt"

strSourceFile = "\\server\share\filename.vbs"

Const ForReading = 1, ForWriting = 2, ForAppending = 8
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile(ComputerList, ForReading, True)

Do While f.AtEndOfLine <> True
  strComputer = f.ReadLine
  strDestination = "\\" & strComputer & "\C$\Documents and Settings\All Users\Start Menu\Programs\Startup\"
  fso.CopyFile strSourceFile, strDestination
Loop

Open in new window

CERTIFIED EXPERT

Commented:
To always create a new URL, use this script...my script only created a new URL.
On Error Resume Next
Set objFSO = CreateObject("Scripting.FileSystemObject")

strFile = "MyFavorite.url"

Set WshShell = CreateObject("WScript.Shell")
strFavorites = WshShell.SpecialFolders("Favorites")

strURLPath = strFavorites & "\" & strFile

If objFSO.FileExists(strURLPath) Then
  objFSO.DeleteFile(strURLPath), TRUE
End If

strURL = "javascript:d=document;i='AddToRWScript';try{RWAddToRW1()" & _
  ";}catch(e){s=d.createElement('script');s.type='text/javascript';s.src=" & _
  "'http://www.refworks.com/refgrabit/rgibookmark.aspx?rgiid=faea0919-8ade-4097-8d89-bbc7108c45c8'" & _
  ";s.id=i;d.getElementsByTagName('head')[0].appendChild(s);}void(0);"

Set objShortcutUrl = WshShell.CreateShortcut(strURLPath)
objShortcutUrl.TargetPath = strURL
objShortcutUrl.Save

Open in new window

Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.