Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: Create Windows XP Shortcut

  1. #1
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719
    Login to Give a bone
    0

    Exclamation Create Windows XP Shortcut

    Can anyone tell me if Visual LISP is capable of creating a shortcut file (Windows Explorer), and can be manipulated for a specific target directory location? If so, where do I begin...?

    I have a project directory structure that greatly benefits from having several shortcuts within the individual directories that makes it quick to jump from, for example, the "...\Sheets\" directoriy into the "...\Exhibits\" directory, etc. (24 in total, presently).

    I currently do this manually (Copy + Paste + Modify), but would like to automate this process as it is project based, and all of the target directories are already defined programmatically with global variables, based on either the 'DWGPrefix sysvar and/or the vla-get-fullname property conditionally.

    Thanks!
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  2. #2
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    9,104
    Login to Give a bone
    0

    Default Re: Create Windows XP Shortcut

    Here is a vbscript function to do just that.

    Code:
    Function MakeShortcut (strName, strFile, strTarget, strDefault, strIcon)
    	Dim objWS, objLink
    	Set objWS = WScript.CreateObject("WScript.Shell")
    	strLinkFile = strFile & "\" & strName & ".lnk"
    	Set objLink = objWS.CreateShortcut(strLinkFile)
    	'Dim objFSO
    	
    	If objFSO.FolderExists(strTarget) Then
    		strTarget = strTarget
    	Else
    		strTarget = strDefault
    	End If
    	If strIcon = "" Then
    		strIcon = "0"
    	End If
    
    	objLink.TargetPath = strTarget
    	objLink.Description = strName
    	objLink.WorkingDirectory = strTarget
    	objLink.IconLocation = "%SystemRoot%\system32\SHELL32.dll, " & strIcon
    	objLink.Save
    	MakeShortcut = objLink
    End Function
    It was developed for Windows XP and may need additional tweaking for other operating systems. You should be able to convert this to Visual LISP with little problem.
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  3. #3
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719
    Login to Give a bone
    0

    Default Re: Create Windows XP Shortcut

    You rock, Opie!

    I'll take a crack at it later today!
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  4. #4
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    9,104
    Login to Give a bone
    0

    Default Re: Create Windows XP Shortcut

    It'll just need a few vlax-invoke-method and vla-put-property calls to make it work. Make sure to escape your slashes and percents.
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  5. #5
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719
    Login to Give a bone
    0

    Default Re: Create Windows XP Shortcut

    Quote Originally Posted by Opie View Post
    It'll just need a few vlax-invoke-method and vla-put-property calls to make it work. ...
    This I understand fully.

    Quote Originally Posted by Opie View Post
    ... Make sure to escape your slashes and percents.
    This I do not; I speculate you mean with regard to the target location(s). Could you clarify the 'escape' part?
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  6. #6
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    9,104
    Login to Give a bone
    0

    Default Re: Create Windows XP Shortcut

    I mispoke regarding the percents and was referring to the \ character for directory related strings.
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  7. #7
    Certifiable AUGI Addict
    Join Date
    2015-11
    Location
    Jo'burg SA
    Posts
    4,512
    Login to Give a bone
    0

    Default Re: Create Windows XP Shortcut

    Quote Originally Posted by Opie View Post
    I mispoke regarding the percents and was referring to the \ character for directory related strings.
    You mean that each back-slash inside the strings (i.e. between the quotes) should be doubled. In lisp "\\" actually means \.

  8. #8
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719
    Login to Give a bone
    0

    Default Re: Create Windows XP Shortcut

    Quote Originally Posted by irneb View Post
    You mean that each back-slash inside the strings (i.e. between the quotes) should be doubled. In lisp "\\" actually means \.
    This I already knew; Opie just lost me with the 'escape' part.
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  9. #9
    AUGI Addict
    Join Date
    2008-02
    Posts
    1,141
    Login to Give a bone
    0

    Default Re: Create Windows XP Shortcut

    I did this a while back...

    Code:
    (defun AT:CreateShortCut (shortcut target / sh sc r)
      ;; Create shortcut of specified file
      ;; shortcut - shortcut to create
      ;; target   - target file/folder to create shortcut of
      ;; Ex: (AT:CreateShortCut (strcat (getenv "userprofile") "\\Desktop\\TEST.lnk") "c:\\FILE.DWG")
      ;; Alan J. Thompson
      (if (findfile target)
        (progn
          (setq r (vl-catch-all-apply
                    '(lambda ()
                       (vlax-put-property
                         (setq sc (vlax-invoke
                                    (setq sh (vlax-create-object "WScript.Shell"))
                                    'CreateShortcut
                                    shortcut
                                  )
                         )
                         'TargetPath
                         target
                       )
                       (vlax-invoke sc 'Save)
                     )
                  )
          )
          (mapcar '(lambda (x) (vl-catch-all-apply 'vlax-release-object (list x))) (list sh sc))
          (not (vl-catch-all-error-p r))
        )
      )
    )

  10. #10
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719
    Login to Give a bone
    0

    Default Re: Create Windows XP Shortcut

    Thanks everyone, for your helpful feedback!

    I feel confident that I can compile a program from the code you've all provided here. I'll let you know if I have any questions; I am just starting to "dabble" with objects outside of AutoCAD.

    When done, I will post the code here for others.

    Cheers!
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

Page 1 of 2 12 LastLast

Similar Threads

  1. create typed shortcut for command group
    By archiasmo954906 in forum API Wish List
    Replies: 5
    Last Post: 2012-10-29, 10:01 PM
  2. Create / Setup shortcut for ALIGN command?
    By Cadtharsis in forum AutoCAD Customization
    Replies: 8
    Last Post: 2007-03-21, 08:11 PM
  3. MDT 2006 - Create shortcut key's
    By Viatcheslav.Samsonov in forum AutoCAD CUI Menus
    Replies: 2
    Last Post: 2006-07-01, 08:12 AM
  4. Create own Shortcut Keys
    By basha_sk312 in forum AutoCAD CUI Menus
    Replies: 2
    Last Post: 2006-03-15, 08:37 PM
  5. Create in Place: Doors & Windows
    By bpayne in forum Revit Architecture - General
    Replies: 4
    Last Post: 2006-03-09, 01:31 PM

Posting Permissions

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