Jump to content

Welcome to MSFN Forum
Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more. This message will be removed once you have signed in.
Login to Account Create an Account


Photo

VBScript to Create Favorites

- - - - -

  • Please log in to reply
8 replies to this topic

#1
mmarable

mmarable

    Advanced Member

  • Member
  • PipPipPip
  • 377 posts
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

"There are three classes of men; lovers of wisdom, lovers of honor, and lovers of gain." - Plato
"Winning is not everything, but wanting to win is." - Vince Lombardi - "If you wait, all that happens is that you get older." - Mario Andretti
"Do it no matter what. If you believe in it, it is something very honorable. If somebody around you or your family does not understand it, then that's their problem. But if you do have a passion, an honest passion, just do it." - Mario Andretti


How to remove advertisement from MSFN

#2
Nologic

Nologic

    Advanced Member

  • Member
  • PipPipPip
  • 461 posts
Thanks this will be most helpful. :)

#3
rustycaps

rustycaps

    Junior

  • Member
  • Pip
  • 98 posts
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
Radimus

Radimus

    Advanced Member

  • Member
  • PipPipPip
  • 309 posts
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
prathapml

prathapml

    Follow the rules please :-)

  • Patrons
  • 6,791 posts
  • OS:Windows 8 x64
  • Country: Country Flag
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.......
Posted ImageCheers !!!   Donate to MSFN and Help Keep This Site Running
||Please Read the Forum Rules||  Etiquette   || Welcome to MSFN - Forum Basics || Before posting
prathapml :: MSFN Supermod :: Private Message me if you ever have a problem while at MSFN

#6
WwTIPPYwW

WwTIPPYwW

    Advanced Member

  • Member
  • PipPipPip
  • 330 posts
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
pastl

pastl

    Newbie

  • Member
  • 21 posts
@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
evilvoice

evilvoice

    Ditchy McAbandonpants

  • Member
  • PipPipPipPipPip
  • 946 posts
seems to work that way...
When I spotted this little cutie with some sex appeal. I winked at her, she gave me a look like I'm a booger. I thought b***h, I'd rather spend my money on a hooker. Then a bright idea ran across my mind, if I could swipe a manikin I'd have a freak all the time.

#9
pastl

pastl

    Newbie

  • Member
  • 21 posts
@evilvoice,

thanks for your answer, I'll try it.

pastl :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users



How to remove advertisement from MSFN