MSFN Forum: VBScript to Create Favorites - MSFN Forum

Jump to content



Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

VBScript to Create Favorites Rate Topic: -----

#1 User is offline   mmarable 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 377
  • Joined: 01-November 03

Posted 06 July 2004 - 11:48 AM

Well, I figured that it was about time I actually contributed something here seeing that I've gotten a lot of help from the forums.

It's a small contribution, but something that I hope is usefull to someone. It's a vb script:
Const ForReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\Install\Favorites.txt", ForReading)
Set objShell = WScript.CreateObject("WScript.Shell")
Set colEnvironmentVariables = objShell.Environment("Volatile")

strQLFolder = "C:" & colEnvironmentVariables.Item("HOMEPATH") & "\Favorites"

WScript.Echo strQLFolder
WScript.Echo

Do While objFile.AtEndOfStream <> True
        arrFAVRecord = split(objFile.Readline, ",")
        Wscript.Echo "Folder: " & arrFAVRecord(0)
        
        If objFSO.FolderExists(strQLFolder & "\" & arrFAVRecord(0)) Then
      Wscript.Echo "Folder exists."
   	 Else
      Set objFolder = objFSO.CreateFolder(strQLFolder & "\" & arrFAVRecord(0))
      Wscript.Echo "Folder does not exist. Creating..."
  End If
        
        Wscript.Echo "Title : " & arrFAVRecord(1)
        Set objURLShortcut = objShell.CreateShortcut(strQLFolder & "\" & arrFAVRecord(0) & "\" & arrFAVRecord(1) & ".URL")
        WScript.Echo "Link  : " & objURLShortcut
'        Wscript.Echo "URL   : " & arrFAVRecord(2)
        objURLShortcut.TargetPath = arrFAVRecord(2)
        WScript.Echo "URL   : " & objURLShortcut.TargetPath
        WScript.Echo
        objURLShortcut.Save
    i = i + 1
Loop

	WScript.Echo "Total Count: " & i

objFile.Close



#2 User is offline   Nologic 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 461
  • Joined: 07-October 03

Posted 06 July 2004 - 03:27 PM

Thanks this will be most helpful. :)

#3 User is offline   rustycaps 

  • Junior
  • Pip
  • Group: Members
  • Posts: 98
  • Joined: 22-November 03

Posted 07 July 2004 - 12:27 AM

Wouldn't it be a lot easier to just have the favorites folder on another partition then have the necessary Shell Folder and User Shell Folder reg entries changed accordingly, e.g.
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders]
"Favorites"="F:\\Favorites"

Ths is cut from the reg file I have to setup my specific folder, some of which are on that same f: partition - "my documents" and "my pictures" mainly, which eliminates the need to back them up each time you reinstall (aside from normal backups of course). I know some people just have a huge 120Gb (111Gb effective) partition or whatever, but partitions make things like this a lot easier.

#4 User is offline   Radimus 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 309
  • Joined: 14-June 04

Posted 07 July 2004 - 06:52 AM

favorites(URLs) are just little text files (INI format)... with only a few lines in them... they can easily be made with a batch and echo statements...

echo c:\MSFN.url > [DEFAULT]
echo c:\MSFN.url >> BASEURL=http://www.msfn.org/board/index.php?act=idx
echo c:\MSFN.url >> [InternetShortcut]
echo c:\MSFN.url >> URL=http://www.msfn.org/board/index.php?act=idx
echo c:\MSFN.url >> Modified=E00313B3D64FC40193
echo c:\MSFN.url >> IconFile=http://www.msfn.org/favicon.ico
echo c:\MSFN.url >> IconIndex=1


you batch writers can easily modify the above example to use variables for the file path

#5 User is offline   prathapml 

  • Follow the rules please :-)
  • Group: Patrons
  • Posts: 6,791
  • Joined: 14-November 03
  • OS:Windows 7 x64
  • Country: Country Flag

Posted 07 July 2004 - 08:02 AM

This, I suppose is called "power of community sharing".
Within less than a day, I see 3 ways of doing something - and whichever you like, use that method.


@mmarable
That's cool (about the script you made).
Hoping you would share more ideas with us.......

#6 User is offline   WwTIPPYwW 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 330
  • Joined: 15-February 04

Posted 07 July 2004 - 08:07 AM

Also - you could use the $OEM$\DOCS folder and add them to the default user folder. I forget the exact folder - but I've added them there.

Also a simple self extracting EXE.

I believe it can also be added to the answer file.

#7 User is offline   pastl 

  • Newbie
  • Group: Members
  • Posts: 21
  • Joined: 26-May 04

Posted 07 July 2004 - 02:44 PM

@mmarable,

What do I have todo if i don't want to create a folder, just using Link Title and URL?

Like That?
,MSFN,http://www.msfn.org/



Thanks for your help.


pastl :)

#8 User is offline   evilvoice 

  • Ditchy McAbandonpants
  • PipPipPipPipPip
  • Group: Members
  • Posts: 946
  • Joined: 27-January 04

Posted 07 July 2004 - 03:11 PM

seems to work that way...

#9 User is offline   pastl 

  • Newbie
  • Group: Members
  • Posts: 21
  • Joined: 26-May 04

Posted 07 July 2004 - 08:29 PM

@evilvoice,

thanks for your answer, I'll try it.

pastl :)

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2011 msfn.org
Privacy Policy