• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 728
  • Last Modified:

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

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.
0
rsnellman
Asked:
rsnellman
  • 4
  • 3
  • 2
  • +1
2 Solutions
 
David LeeCommented:
Hi, rsnellman.

You can create a URL shortcut (example attached) and then deploy it to all computers via a logon script or, possibly, via group policy.  EE doesn't allow uploading a file with a .url extension, so I changed the extension to .txt.  Change it back to .url.
rsnellman.txt
0
 
Tony MassaCommented:
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

0
 
rsnellmanIT ManagerAuthor 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?
0
Protect Your Employees from Wi-Fi Threats

As Wi-Fi growth and popularity continues to climb, not everyone understands the risks that come with connecting to public Wi-Fi or even offering Wi-Fi to employees, visitors and guests. Download the resource kit to make sure your safe wherever business takes you!

 
koiboi86Commented:
a simple thing would be to just save the 'favorite' on a network location. create a simple batch file such as

xcopy 'file location' 'to user\favorites'

exit

and setup the batch to be a start up script on your group policy.
0
 
David LeeCommented:
koiboi86 hit the nail on the head.  That's exactly how I'd copy the file.  
0
 
Tony MassaCommented:
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

0
 
rsnellmanIT ManagerAuthor 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.
0
 
rsnellmanIT ManagerAuthor 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.

0
 
Tony MassaCommented:
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

0
 
Tony MassaCommented:
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

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 3
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now