5 pts.
 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

Software/Hardware used:
ASKED: April 29, 2009  6:22 AM
UPDATED: October 5, 2009  5:41 PM

Answer Wiki:
Save the following code to VBS extension <pre>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</pre> ++++++++++++++ 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%DebugFavoritesUpdate.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 SettingsAll Users" GOTO :EOF IF /i "%T101%"=="D:Documents and SettingsDefault User" GOTO :EOF IF /i "%T101%"=="D:Documents and SettingsNetworkService" GOTO :EOF IF /i "%T101%"=="D:Documents and SettingsLocalService" 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 \MySrvrMyShareMyfolder "%T101%Favorites" *.lnk /R:5 /W:3 /NP /Z /XX /TEE /LOG+:%SystemRoot%DebugFavoritesUpdate_RC.log >>%LOG% robocopy \MySrvrMyShareMyfolder "%T101%Favorites" *.lnk /R:5 /W:3 /NP /Z /XX /TEE /LOG+:%SystemRoot%DebugFavoritesUpdate_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 Wiki Answer Submitted:  October 5, 2009  5:41 pm  by  carlosdl   63,535 pts.
All Answer Wiki Contributors:  carlosdl   63,535 pts. , Pjb0222   3,310 pts. , alessandro.panzetta   9,660 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

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

 63,535 pts.

 

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

strDesktopPath = WshShell.SpecialFolders(“Desktop”)

with this one:

strDesktopPath = WshShell.SpecialFolders(“Favorites“)

 63,535 pts.

 

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


 

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

 80 pts.

 

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…

 10 pts.

 

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
 63,535 pts.