Results 1 to 8 of 8
  1. #1
    Super Moderator WebGenii's Avatar
    Join Date
    Jan 2001
    Location
    Redcliff, Alberta, Canada
    Posts
    4,066
    Thanks
    2
    Thanked 5 Times in 5 Posts

    Editing Shortcuts via a batch file?

    Is it possible to edit shortcuts using a batch file?
    My scenario - I have a group of shortcuts I use to launch an Access DB in various configurations. For backup purposes I copy the folder containing the shortcuts and DB to a new folder daily. So the shortcuts all have to be updated with the new path. Opening 6+ shortcuts to edit manually is annoying (but not fatal) so it got me wondering about an update with a batch file.

    Thanks
    [b]Catharine Richardson (WebGenii)
    WebGenii Home Page
    Moderator: Spreadsheets, Other MS Apps, Presentation Apps, Visual Basic for Apps, Windows Mobile

  2. #2
    Silver Lounger
    Join Date
    Apr 2001
    Location
    New York, New York, USA
    Posts
    2,328
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Editing Shortcuts via a batch file?

    You can create shortcuts using VBS file.

    This is an example (from Microsoft):

    ' ************************************************** ******************************
    ' *
    ' * Shortcut related methods.
    ' *

    Dim WSHShell
    Set WSHShell = WScript.CreateObject("WScript.Shell")


    Dim MyShortcut, MyDesktop, DesktopPath

    ' Read desktop path using WshSpecialFolders object
    DesktopPath = WSHShell.SpecialFolders("Desktop")

    ' Create a shortcut object on the desktop
    Set MyShortcut = WSHShell.CreateShortcut(DesktopPath & "Shortcut to notepad.lnk")

    ' Set shortcut object properties and save it
    MyShortcut.TargetPath = WSHShell.ExpandEnvironmentStrings("%windir%notepad .exe")
    MyShortcut.WorkingDirectory = WSHShell.ExpandEnvironmentStrings("%windir%")
    MyShortcut.WindowStyle = 4
    MyShortcut.IconLocation = WSHShell.ExpandEnvironmentStrings("%windir%notepad .exe, 0")
    MyShortcut.Save

    WScript.Echo "A shortcut to Notepad now exists on your Desktop."

    ' ************************************************** ******************************

    If your new folder is created every day using certain rules, you can automate this process by automatically changing second argument in Set MyShortcut line. Remember, a new shortcut will override previous one without any warning.

  3. #3
    3 Star Lounger
    Join Date
    Feb 2003
    Location
    Runcorn, Cheshire, United Kingdom
    Posts
    372
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Re: Editing Shortcuts via a batch file?

    Would it make more sense to think of the copy as the backup and keep the production file in the same folder? No need to update the shortcuts and the folder/files can be made read-only as soon as they are copied.

  4. #4
    Super Moderator WebGenii's Avatar
    Join Date
    Jan 2001
    Location
    Redcliff, Alberta, Canada
    Posts
    4,066
    Thanks
    2
    Thanked 5 Times in 5 Posts

    Re: Editing Shortcuts via a batch file?

    Well, that's a logical approach I like!
    [b]Catharine Richardson (WebGenii)
    WebGenii Home Page
    Moderator: Spreadsheets, Other MS Apps, Presentation Apps, Visual Basic for Apps, Windows Mobile

  5. #5
    Platinum Lounger
    Join Date
    Jan 2001
    Location
    Quedgeley, Gloucester, England
    Posts
    5,333
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Editing Shortcuts via a batch file?

    Catherine

    To change a shortcut I would use the old NT4 Resource Kit utility called SHORTCUT, or perhaps a similarly named one from Marty List, here via Jerry Shulman's RegHacks website.

    Is there any rule which defines the new path name? If, say, it contains the date, then a BATch file could be knocked up fairly easily. Just describe what you want!

    John
    <font face="Script MT Bold"><font color=blue><big><big>John</big></big></font color=blue></font face=script>

    Ita, esto, quidcumque...

  6. #6
    Super Moderator WebGenii's Avatar
    Join Date
    Jan 2001
    Location
    Redcliff, Alberta, Canada
    Posts
    4,066
    Thanks
    2
    Thanked 5 Times in 5 Posts

    Re: Editing Shortcuts via a batch file?

    The new subdirectory is always something like June23_2004.
    [b]Catharine Richardson (WebGenii)
    WebGenii Home Page
    Moderator: Spreadsheets, Other MS Apps, Presentation Apps, Visual Basic for Apps, Windows Mobile

  7. #7
    Silver Lounger
    Join Date
    Apr 2001
    Location
    New York, New York, USA
    Posts
    2,328
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Editing Shortcuts via a batch file?

    I agree with Gfamily - create the folder called "Today" or "Current" and rename it to "June23_2004" when you need to create a new one. The reason is: somebody else can create a shortcut also if folders are on the server.

  8. #8
    Bronze Lounger
    Join Date
    Nov 2001
    Location
    Arlington, Virginia, USA
    Posts
    1,394
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Re: Editing Shortcuts via a batch file?

    If you want to do this from Access itself (or Visual Basic) you can use Windows Script Host in VB/VBA. For sample code see attached text file (exported code module from an Access db). The ResetShortcutProperties procedure takes one argument, the new path where database file & shortcuts are located, and updates any shortcut file (.LNK) found in specified folder. Typically I need to do this for secured databases, where it is necessary to specify path to workgroup file, etc in the shortcut arguments. The procedure worked correctly with both secured db and non-secured db shortcuts. Code may have to be modified depending on how the shortcuts are configured; the sub assumes that path/name of database file is always first argument following target (path to executable), followed by path/name of workgroup file, then any other options. The paths are delimited by double-quotes in event of spaces in path. Code requires references to WSH and Scripting Runtime as noted in comments at top of module.

    HTH

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •