WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Shortcut Information

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Shortcuts to URLs

Keywords: 	 Shortcuts to URLs

Question:

I am trying to read ShortCutInfo() and if necessary modify it using ShortCutEdit(). This has been working fine but now I've run into a new twist.

If the shortcut is to a URL instead of a standard .EXE the ShortCutEdit() function can't seem to read the Target as it is now called Target URL.

Anyone know how to make ShortCutInfo() read the Target URL: ?

Answer:

Here is some OLE code that can create it:
WshShell = CreateObject("WScript.Shell")
strDesktop   = WshShell.SpecialFolders("Desktop")
oUrlLink = WshShell.CreateShortcut(StrCat(strDesktop , "\Microsoft Web Site.url"))
oUrlLink.TargetPath = "http://www.microsoft.com"
oUrlLink.Save
oUrlLink = 0
WshShell = 0

URL shortcuts are not real shortcuts.

They are INI files.

  1. Use IniReadPvt to read them.

  2. Be sure to include the .url extension on the ini file name.

  3. Looking at the shortcut in a console window will help you figure out what is going on.

  4. Try the TYPE command on it.

Question 2:

I am attempting to specify a URL as a target, with ShortcutMake. However, It doesn't seem to create a valid shortcut. Somehow c:\ is getting concatenated to the beginning. Any Thoughts?

Answer 2:

Really shortCutmake was designed to create shortcuts for files or directories. If you want to create an 'Internet shortcut' try the following code:


IniWritePvt ("InternetShortcut", "URL", "http://techsupt.winbatch.com", "C:\Windows\desktop\Internet.URL")

Question 3:

I am getting an error on the ShortcutExtra function, (which is no surprise after what I've learned). The only thing is, I am unsure how I would specify the icon I want through the IniWritePvt function (or is there another way?).

I am using the following code:


ShortcutExtra("Help Desk.URL", "", "", "%dir%help.ico", "0")

Let me know if you have any ideas.

Answer 3:

The shortcuts functions are not designed for the file type URL (Internet shortcut).

It should be able to be done as follows: You could 'INI' write the following lines to the 'URL' file


Content of URL file.....
------------------------
[InternetShortcut]
URL=http://172.21.36.97/c3.nsf
IconFile=i:\apps\help\help.ico
IconIndex=0
Modified=20128462C7D2BE0170

I am not sure exactly what the 'modified' line does, but this is what gets written to the URL file when I manually changed the icon via the "properties" dialog for the internet shortcut.

There may also be the issue of forcing the 'INI' updates to disk. We have found that a single IniWritePvt with blank strings forces the update to disk.


IniWritePvt("","","","%cd%\Help Desk.URL")

Your code would look some like the following:


;Content of URL file
;-------------------
;[InternetShortcut]
;URL=http://www.yahoo.com/
;IconFile=D:\Backups\CSource\02_24_99\MAPI2\MFETCH\GRAYCAT.ICO
;IconIndex=0
;Modified=20128462C7D2BE0170


IniWritePvt ("InternetShortcut", "URL", "http://www.yahoo.com/", "c:\Windows\desktop\test.URL")
IniWritePvt ("InternetShortcut", "IconFile", "D:\Backups\CSource\02_24_99\MAPI2\MFETCH\GRAYCAT.ICO", "c:\Windows\desktop\test.URL")
IniWritePvt ("InternetShortcut", "IconIndex", "0", "c:\Windows\desktop\test.URL")
IniWritePvt ("InternetShortcut", "Modified", "20128462C7D2BE0170", "c:\Windows\desktop\test.URL")
;For good measure (force updates to disk)
IniWritePvt ("", "", "", "c:\Windows\desktop\test.URL")
exit




Article ID:   W13857
Filename:   Shortcuts to URLs.txt
File Created: 2017:08:29:11:19:22
Last Updated: 2017:08:29:11:19:22