Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Command line to create short cut  (Read 5680 times)

0 Members and 1 Guest are viewing this topic.

Eric.Harris

    Topic Starter


    Newbie

    • Experience: Familiar
    • OS: Windows 7
    Command line to create short cut
    « on: June 04, 2017, 12:43:32 PM »
    Hi,
    I have searched but just don't seem to be able to get an answer.
    I'm trying to create a shortcut using a .bat file.
    It runs a program which in effect runs an access applicatioin.
    However, I want to supply command argumants to the target of the shortcut.
    The following contents of the batch work fine.
    However I want to add the comman arguments on the end and am Having trouble.

    here's the script that works

    @echo off
    echo Set oWS = WScript.CreateObject("WScript.Shell") > P:\docs\h\g\h\hgh1\1\CreateShortcut.vbs
    echo sLinkFile = "P:\docs\h\g\h\hgh1\1\Review.lnk" >> CreateShortcut.vbs
    echo Set oLink = oWS.CreateShortcut(sLinkFile) >> CreateShortcut.vbs
    echo oLink.TargetPath = "\\pts-app\partner\PTS-Apps\Partner_Review.accdb" >> CreateShortcut.vbs
    echo oLink.Save >> CreateShortcut.vbs
    cscript CreateShortcut.vbs
    del CreateShortcut.vbs

    As you can see, the target path is :- \\pts-app\partner\PTS-Apps\Partner_Review.accdb

    However, I need it to be :- \\PTS-APP\Partner\PTS-Apps\Partner_Review.accdb /cmd "XXX000000000031|1|"

    Any ideas on how to generate that. The quotes are driving me mad.


    Geek-9pm


      Mastermind
    • Geek After Dark
    • Thanked: 1026
      • Gekk9pm bnlog
    • Certifications: List
    • Computer: Specs
    • Experience: Expert
    • OS: Windows 10
    Re: Command line to create short cut
    « Reply #1 on: June 04, 2017, 04:26:40 PM »
    There is a program to create shortcuts in batch.
    SHORTCUT.EXE   (Google it.)
    Did you already read this?
    https://superuser.com/questions/392061/how-to-make-a-shortcut-from-cmd
    It says:
    Quote
    Seems like there is some shortcut.exe in some resource kit which I don't have.
    As many other sites mention, there is no built-in way to do it from a batch file.
    It is from the Windows 95 support tools and NT 4 Server Resource Kit.
    Unfortunately, there are are other programs with the same or similar name and do not do the same thing.
    Here is more information:
    https://ss64.com/nt/shortcut.html
    Let me know if you want to consider SHORTCUT.EXE

    BC_Programmer


      Mastermind
    • Typing is no substitute for thinking.
    • Thanked: 1140
      • Yes
      • Yes
      • BC-Programming.com
    • Certifications: List
    • Computer: Specs
    • Experience: Beginner
    • OS: Windows 11
    Re: Command line to create short cut
    « Reply #2 on: June 04, 2017, 04:41:11 PM »
    You want to set the Arguments property. The Target Path must point at a file and cannot have arguments. Quotes are escaped in VBscript by doubling them up.

    Code: [Select]
    echo oLink.TargetPath = "\\pts-app\partner\PTS-Apps\Partner_Review.accdb" >> CreateShortcut.vbs
    echo oLink.Arguments = "/cmd ""XXX000000000031|1|""" >> CreateShortcut.vbs

    However, this might not work. it depends how accdb file types are associated and how they are launched.
    I was trying to dereference Null Pointers before it was cool.

    Eric.Harris

      Topic Starter


      Newbie

      • Experience: Familiar
      • OS: Windows 7
      Re: Command line to create short cut
      « Reply #3 on: June 09, 2017, 06:59:55 AM »
      New to this site so apologies if I'm posting n the wrong place.
      THis is brilliant. THanks you so much.
      It worked a treat.



      You want to set the Arguments property. The Target Path must point at a file and cannot have arguments. Quotes are escaped in VBscript by doubling them up.

      Code: [Select]
      echo oLink.TargetPath = "\\pts-app\partner\PTS-Apps\Partner_Review.accdb" >> CreateShortcut.vbs
      echo oLink.Arguments = "/cmd ""XXX000000000031|1|""" >> CreateShortcut.vbs

      However, this might not work. it depends how accdb file types are associated and how they are launched.