Add to Favorites in Internet Explorer with batch file
5 pts.
0
Q:
Add to Favorites in Internet Explorer with batch file
i want to add url link to internet explorer by using batch commands in a batch file.For example, i want to add follwoing link
http://itknowledgeexchange.techtarget.com/itanswers/

using batch commands.
Thanx
ASKED: Apr 29 2009  6:22 AM GMT
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
0
29855 pts.
0
A:
 RATE THIS ANSWER
0
Click to Vote:
  •   1
  •  -1
  • AddThis Social Bookmark Button
Save the following code to VBS extension

Set WshShell = CreateObject("WScript.Shell")
strDesktopPath = WshShell.SpecialFolders("Desktop")
Set objShortcutUrl = WshShell.CreateShortcut(strDesktopPath & "\IT Answers.url")
objShortcutUrl.TargetPath = "http://itknowledgeexchange.techtarget.com/itanswers/"
objShortcutUrl.Save


++++++++++++++

A windows command script. Unwrap the FOR loops and robocopies.

==============
@ECHO OFF
REM This script assumes that the Windows Resource Kit tools are installed and in the path.
REM Remove the NOW command lines if not available.
REM This assumes running on the target machine.
REM Modify it to your needs.

if not exist %SystemRoot%\Debug\. md %SystemRoot%\Debug
Set log=%SystemRoot%\Debug\FavoritesUpdate.log

ECHO. >>%LOG%
Now >>%LOG%
ECHO. >>%LOG%
ECHO Process each profile directory to add shortcuts
ECHO Process each profile directory to add shortcuts >>%log%
REM Pull out the root of the profile path
REM If you have moved the profile directory, this may need to be modified.
FOR /F "tokens=1,2 delims=\ usebackq" %%a IN (`Echo %USERPROFILE%`) DO SET ProfilePathRoot=%%a\%%b
REM Process each profile directory
for /d %%B in ("%ProfilePathRoot%\*") do CALL :CopySC "%%B"
ECHO. >>%LOG%
ECHO Completed processing profile directories
ECHO Completed processing profile directories >>%LOG%
ECHO. >>%LOG%

goto :DONE

:CopySC
REM Strip double quotes
SET T101=%1
set T101=%T101:~1,-1%
REM Skip non-user profiles
IF /i "%T101%"=="D:\Documents and Settings\All Users" GOTO :EOF
IF /i "%T101%"=="D:\Documents and Settings\Default User" GOTO :EOF
IF /i "%T101%"=="D:\Documents and Settings\NetworkService" GOTO :EOF
IF /i "%T101%"=="D:\Documents and Settings\LocalService" GOTO :EOF

ECHO. >>%LOG%
ECHO Processing directory %T101%
ECHO Processing directory %T101% >>%LOG%
ECHO. >>%LOG%

ECHO Validate the favorites directory exists >>%LOG%
IF NOT EXIST "%T101%\Favorites" (
ECHO Directory "%T101%\Favorites" not found, skipping
ECHO Directory "%T101%\Favorites" not found, skipping >>%LOG%
GOTO :EOF
)

REM Replace the dummy source path with the location of your shortcuts.
REM Ensure that the credentials you run this under have access to the files.
ECHO robocopy \\MySrvr\MyShare\Myfolder "%T101%\Favorites" *.lnk /R:5 /W:3 /NP /Z /XX /TEE /LOG+:%SystemRoot%\Debug\FavoritesUpdate_RC.log >>%LOG%
robocopy \\MySrvr\MyShare\Myfolder "%T101%\Favorites" *.lnk /R:5 /W:3 /NP /Z /XX /TEE /LOG+:%SystemRoot%\Debug\FavoritesUpdate_RC.log
if errorlevel 4 (
SET EL=%errorlevel%
GOTO :RCopyFail
)
ECHO Returned ErrorLevel - %errorlevel% >>%LOG%
ECHO. >>%LOG%
SET T101=
GOTO :EOF

:RCopyFail
ECHO. >>%LOG
%ECHO Returned ErrorLevel - %EL% >>%LOG%
ECHO Failed to copy files to directory %T101%
ECHO Failed to copy files to directory %T101% >>%LOG%
ECHO. >>%LOG%
SET T101=
SET EL=
GOTO :EOF

:DONE
ECHO. >>%LOG%
now >>%LOG%
ECHO. >>%LOG%
Set log=
==============
Last Answered: Oct 5 2009  5:41 PM GMT by Carlosdl   29855 pts.
Latest Contributors: Pjb0222   1110 pts., Alessandro.panzetta   9615 pts.
0
0
Discuss This Answer:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

Carlosdl   29855 pts.  |   Apr 29 2009  1:36PM GMT

Notice that the above script will create a shortcut in the desktop, not a favorite in Internet Explorer.

 

Carlosdl   29855 pts.  |   Apr 29 2009  1:55PM GMT

To create the shortcut in the Favorites folder just replace this line:

strDesktopPath = WshShell.SpecialFolders(”Desktop”)

with this one:

strDesktopPath = WshShell.SpecialFolders(”Favorites“)

 

Alessandro Panzetta   0 pts.  |   Apr 29 2009  3:08PM GMT

You’re right, that was copy&paste too quick :)

 

Toggler   80 pts.  |   May 26 2009  2:35PM GMT

I am actually attempting to do the same thing only I want mine to be added automatically to the links toolbar in IE..

can it be done at all via either the registry or batch file?

thanks
Dan

 

Sliverme   10 pts.  |   Oct 1 2009  1:46PM GMT

Thanks Carlosdl, works great. Is there a way to edit it so that I could run it as administrator and have it affect all users desktops? Thanks again…

 

Carlosdl   29855 pts.  |   Oct 2 2009  2:14PM GMT

I thought we could use the “AllUsersFavorites” special folder, but the SpecialFoders function does not find such a folder.

So, we can use the “AllUsersDesktop” special folder, and then replace “Desktop” with “Favorites” in the returned path.

I have not tested it, but I think this should work:

Set WshShell = CreateObject(”WScript.Shell”)
strPath = replace(WshShell.SpecialFolders(”AllUsersDesktop”),”Desktop”,”Favorites”)
Set objShortcutUrl = WshShell.CreateShortcut(strPath  & “IT Answers.url”)
objShortcutUrl.TargetPath = “http://itknowledgeexchange.techtarget.com/itanswers/”
objShortcutUrl.Save

 
0