Page 1 of 1

Create links with RoboTask

Posted: Fri Jan 02, 2009 12:01 pm
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?

Create links with RoboTask

Posted: Sat Jan 03, 2009 10:56 am
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
 

Create links with RoboTask

Posted: Sun Jan 04, 2009 12:40 am
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.

Create links with RoboTask

Posted: Sun Jan 04, 2009 6:12 am
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