Create links with RoboTask

Discuss RoboTask here
Post Reply
wilko0070
Posts: 3
Joined: Fri Jan 02, 2009 11:48 am
Location: Austria

Create links with RoboTask

Post by wilko0070 »

I manage my file system like a relational database. For that I need many links. Is there a facility in RoboTask to create links easily?
wilko0070
Posts: 3
Joined: Fri Jan 02, 2009 11:48 am
Location: Austria

Create links with RoboTask

Post by wilko0070 »

I found a good solution myself. I used this internal BASIC script:
Sub Main
Dim sShortcutPath As String, sExtension As String
Dim fs As New FileSystemObject
Dim oShell As New WshShell
sShortcutPath = InputBox("Enter path and filename of link file: ")
If sShortcutPath <> "" Then
   sExtension = fs.GetExtensionName(sShortcutPath)
   Select Case sExtension
      Case "lnk"
         Dim oShortcut As WshShortcut
         Set oShortcut =  oShell.CreateShortcut(sShortcutPath)
         oShortcut.Save
      Case "url"
      Dim oURLShortcut As WshURLShortcut
         Set oURLShortcut = oShell.CreateShortcut(sShortcutPath)
        oURLShortcut.Save
      Case Else
   MsgBox "Missing extension!"
         ' user input an invalid path or filename; display an error and
         ' exit
         Exit Sub
   End Select
End If
End Sub

For the Wsh objects I set a reference to the Windows Script Host Object model.
If anybody else is interested in an excellent explanantion, here is an URL:
http://www.windowsdevcenter.com/pub/a/w ... /04/13/VB_ Shortcuts.html?page=1
 
Oleg
Site Admin
Posts: 3202
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Create links with RoboTask

Post by Oleg »

Good solution

But you forgot to tell that the link to "Windows Script Host Object Model" is required.
See menu "Edit | References" in script editor.

Also, I see that the created shortcuts are empty. Do you want to fill in they manually?

Thank you for the idea. We'll add such action in future.
wilko0070
Posts: 3
Joined: Fri Jan 02, 2009 11:48 am
Location: Austria

Create links with RoboTask

Post by wilko0070 »

Oleg wrote:But you forgot to tell that the link to "Windows Script Host Object Model" is required.
No. Please read the last passage.
Oleg wrote: Also, I see that the created shortcuts are empty. Do you want to fill in they manually?
Yes. I used the example only to test the link creating. In my task I use the property "RelativePath" of the WshShortcut Object to fill the shortcut.
Oleg wrote:We'll add such action in future.

That's a very great idea! By the way I found a code example for a "low level access" to the SHELL32.DLL with Basic without need of the "Windows Script Host Object Model":
http://vbcity.com/pubs/article.asp?alias=shortcut
 
 
Post Reply