LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Adding parameters to shortcuts in labview installer

Profit,

 

Although I don't see anything in LabVIEW that specifically lets you do it in there directly, there is an alternative that you could try to achieve the same thing. The link below describes how to include a bat file (you could also use a ps1 file, if you are comfortable with powershell) in order to create the shortcut with parameters and such: http://digital.ni.com/public.nsf/allkb/B1D72035B30285C4862577C7004B0B61?OpenDocument. The script would run after the installer is finished, and you would be able to use those script languages in order to achieve whatever you need.

 

Thank you for taking advantage of our idea exchange, and if you post the link to the feature idea on here, I'm sure there are a lot of people that will kudos the idea.

David M.
Applications Engineer
National Instruments
0 Kudos
Message 11 of 20
(1,735 Views)

okay so here is the link to the idea exchange http://forums.ni.com/t5/LabVIEW-Idea-Exchange/Add-shortcut-option-quot-arguments-quot-to-installer/i...

 

6 kudos so far.

 

I think im going to create another one similar to this. There are way more options that an installer should be able to do. Like "run as admin" for windows 7. and all the available properties you see when you click on a shortcut and goto properties. why dont we have control over how the shortcut properties are setup. Well theres not much in there.

 

But run as admin would be a great thing to add. since UAC and windows 7 has a lot locked down if your not at admin run level. My work pc's are locked and i can't write files without having admin rights on the app.

- A minute saved is a Minute earned!
0 Kudos
Message 12 of 20
(1,717 Views)

Well im at it again. Writing applications that require arguments in the shortcut

I have a ApplicationLauncher that requires the application name you want to launch as an argumnet. Now how do i get this shortcut from the installer to include the argument i need 😞

 

I gave up last time and just wrote my own labview TFTP server and embeded it in my design. That way i didn't have to add the tftp file path as and argument when creating shortcuts.

 

Basicly i need the installer to create a desktop shortcut with "<application path>\ApplicationLauncher.exe Application.exe" This really needs to be in the LabView installer somehow.

 

If i create a bat file and have it run at the end of the install how would i know where it was installed too? I guess i know the desktop will have the shortcut and maybe i only modify that......but im on domain pc's so c:\users\<some random user\desktop\shortcut or c:\Documents and Settings\All Users\Desktop for XP and some other location for windows 7

 

Everyone kudo the link http://forums.ni.com/t5/LabVIEW-Idea-Exchange/Add-shortcut-option-quot-arguments-quot-to-installer/i.... so we can get this added to the next version of labview 🙂

 

-Corey

- A minute saved is a Minute earned!
0 Kudos
Message 13 of 20
(1,662 Views)

This is one monster of a workaround, but seeing as this never got an actual answer, allow me to share what I did:

 

1. You're going to need to create a VBScript file that can create shortcuts.  For some reason, you cannot create actual shortcuts in the Windows command line or even in PowerShell, but the ability to do it with VBScript exists.  I found the basic script here: https://www.giannistsakiris.com/2008/12/03/how-to-create-shortcuts-in-windows-from-the-command-line/... The script actually needs one extra line to work for our purposes, though, in order to add parameters to the shortcut.  Your "mkshortcut.vbs" in its entirety should look like this:

 

set WshShell = WScript.CreateObject("WScript.Shell" )
set oShellLink = WshShell.CreateShortcut(Wscript.Arguments.Named("shortcut") & ".lnk")
oShellLink.TargetPath = Wscript.Arguments.Named("target")
oShellLink.Arguments = Wscript.Arguments.Named("params")
oShellLink.WindowStyle = 1
oShellLink.Save

 

2. It's not enough to just have the VBScript; you'll also need a .bat file to actually call the script with the arguments you want.  In the file, you'll specify the Start Menu directory you want your shortcuts as well as the shortcuts themselves.  Here is an example of my "Create Shortcuts With Params.bat":

 

mkdir "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\My New Application"
mkshortcut.vbs /target:"My New Application.exe" /params:"-LOUD" /shortcut:"C:\ProgramData\Microsoft\Windows\Start Menu\Programs\My New Application\Loud Version"
mkshortcut.vbs /target:"My New Application.exe" /params:"-SOFT" /shortcut:"C:\ProgramData\Microsoft\Windows\Start Menu\Programs\My New Application\Soft Version"
mkshortcut.vbs /target:"My New Application.exe" /params:"-SILENT" /shortcut:"C:\ProgramData\Microsoft\Windows\Start Menu\Programs\My New Application\Silent Version"

 

3. You'll need one last .bat file to delete this shortcut folder during uninstallation, since we are modifying external files outside the control of our auto-generated installer.  This one is just a single line.  Your "Delete Shortcuts Folder.bat" should look like this:

 

rmdir /S /Q "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\My New Application"

 

4. After you have saved these files, put them in a "Resources" folder or somewhere else in your LabVIEW project.

 

image.png

 

5. Open the properties of your LabVIEW installer you are making for your application.  Once open, navigate to the "Source Files" item and make sure that all three files will be installed with all your executables.

 

image.png

 

6. Move to the Advanced category of the properties menu.  Check the "Run executable at end of installation" and select "Create Shortcuts With Params.bat"; then check "Run executable before uninstallation" and select "Delete Shortcuts Folder.bat".

 

image.png

 

And that should get you the outcome you were hoping for.  I haven't actually run this yet; I just unit tested lines from the batch files beforehand and made sure that the code in mkshortcut.vbs worked the way it was supposed to, so I'm sorry if you need to do a little tweaking on your own while following these instructions, but hopefully this all works first try for anyone else who comes here looking for a solution LabVIEW really should have provided in the 7 years since this post was first made.

 

EDIT: Fixed typos

0 Kudos
Message 14 of 20
(1,459 Views)

There must be a limit on the number of edits you can do to a post, because I cannot find a way to edit my previous response.  I finally got my LabVIEW program to a point where I could test the information from the previous post.  It was close, but there are two changes that need to be made to my "Create Shortcuts With Params.bat" file.

 

1) The .bat file is run with the command line context being wherever you run the installer from.  As such, exact paths to the installation directory are needed.

2) In LabVIEW executables, arguments are passed with " -- [space_hyph_hyph_space_arg]" instead of "-[space_hyph_arg]".  As such, the .bat file should look more like this:

 

mkdir "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\My New Application"
"%~dp0mkshortcut.vbs" /target:"%~dp0My New Application.exe" /params:"-- LOUD" /shortcut:"C:\ProgramData\Microsoft\Windows\Start Menu\Programs\My New Application\Loud Version"
"%~dp0mkshortcut.vbs" /target:"%~dp0My New Application.exe" /params:"-- SOFT" /shortcut:"C:\ProgramData\Microsoft\Windows\Start Menu\Programs\My New Application\Soft Version"
"%~dp0mkshortcut.vbs" /target:"%~dp0My New Application.exe" /params:"-- SILENT" /shortcut:"C:\ProgramData\Microsoft\Windows\Start Menu\Programs\My New Application\Silent Version"

 

The batch argument "%~dp0" gets the folder that the batch file is located in, including the final backslash.  This makes sure the commands find the VBScript file and the EXE we are making a shortcut to.

0 Kudos
Message 15 of 20
(1,450 Views)

@maluigario wrote:

There must be a limit on the number of edits you can do to a post, because I cannot find a way to edit my previous response. 


Not a number, but a tiime.  I don't remember the exact time limit, but it is something like 20 minutes after the original post you can continue to make edits.  You were trying to edit a 6 day old post.  Too long ago.Smiley Wink

0 Kudos
Message 16 of 20
(1,444 Views)

Oh wow! That really is a monster workaround.

 

Looks like NI still hasn't added the "Shortcuts with arguments" suggestion to the installer.

Somehow this feature suggestion from 2012 (over 11 years ago as of the writing of this post) is still classified as "new"???

 

I think I'm just going to have to add my own "create shortcuts" step to the "Run executable at the end of installation" exe I've made in LabVIEW. Hopefully wont need any extra vbs or bat files, just need ActiveX to keep working in LabVIEW for a while longer.

Troy - CLD "If a hammer is the only tool you have, everything starts to look like a nail." ~ Maslow/Kaplan - Law of the instrument
0 Kudos
Message 17 of 20
(728 Views)

Hi to everyone.

I can't believe I still get updates on a post I tried to reply to in 2008 when I was still a young NI employee. (gt_3000)

 

It's worth noting that the Installer technology in LabVIEW Application Builder hasn't really been updated, and in some circles of the LabVIEW community, is considered 'still there' for legacy purposes.  NI has made great strides with the NI Package Manager and the NI Package Builder.   Although more complex to initially get your head around, I find deploying software to my clients as a an 'NI Package' a lot more convenient.  (It's actually now the default distribution tool for TestStand 202x, as well.)  When you create a package, you have six stages of 'pre' and 'post' installing your application where you can run any batch or PowerShell script.   Under the hood, the package system borrows from the Debian open source community, so it's a tried and tested system from the Linux repository world, just with NI extensions on the file types and 100% compatibility on Windows, since this is what NI uses for its own installers, now.

 

To experience NI Packages, after you create an 'application' using the Application Builder, right-click and create a 'package' instead of installer.  After getting familiar with how it works, consider downloading the free tool 'NI Package Builder', which can help make a new kind of installer, with NI Package Manager built in, rather than the classic *msi tools.  Then consider making a new post on the NI Package forums if you need further help.  Those that use these tools are also pretty good at the pre- and post- scripting to achieve their result, as all they focus on is deployment (like me).  

 

I don't want to make it sound simple, but I do want to highlight that it is more structured.

George T. of Thetic Engineering Ltd.
Consulting in the UK on Test Strategy with TestStand, LabVIEW, NI STS, PXI, and Python
Message 18 of 20
(699 Views)

Thanks @gt_thetic

I appreciate the suggestion to try NI Package Manager.  I guess I've just had my head down coding for too long without time to check out the latest functionality.

 

I would hope that if NI was no longer maintaining or developing a function like "Build Installer" then they would somehow indicate this by flagging it as deprecated or something.

 

The major packages that I maintain pre-date the NI Package Manager by quite a few years, so using it from the beginning wasn't an option.  I use a fairly simple 7zip sfx package builder batch file to package everything up in an easy installer.

 

Most of the target systems are isolated from the internet so installing a package manager that wants to check for updates seems like more of a nuisance having to turn all of that off.

 

I have a fairly simple solution that 'just works'.  Moving to another method would take a fair chunk of time implementing and testing.  I need a better reason to make the change than "it's what all the cool kids are using these days". I guess if it is no longer being updated or maintained then that is a good reason.

 

NI should really update the status of any suggestions related to deprecated features to "Rejected" and state the reason as "Suggestion is related to a feature which has been deprecated. Consider using [the new fancy thing] instead", or something like that.  Don't just leave us hanging.

Otherwise developers like me, looking for a solution in the forums, hit a dead end in a suggestion that has been relegated to the (NI engineers haven't looked at this for decades) backlog.

I'm sure I'm not the only LabVIEW developer who is left with the impression that NI doesn't care about user suggestions because there appears to be no feedback or status updates in the Idea Exchange.

Troy - CLD "If a hammer is the only tool you have, everything starts to look like a nail." ~ Maslow/Kaplan - Law of the instrument
0 Kudos
Message 19 of 20
(677 Views)

Hi Troy,

 

I can't speak for NI since I haven't work for them for a few years, but I can add my experience with both installers and the Ideas Exchange.

Regarding installers:

As I said, the community believes that this feature is 'mature', meaning it will continue to exist, but no new bells and whistles should be expected.  The underlying technology in the Windows world is also considered mature, with so many other ways to install software on Windows.  So I wouldn't go as far as calling it deprecated.  Deprecated status of features normally is announced by NI and put in the Release Notes and Help files for LabVIEW. 

I like your idea with the self-extracting 7-zip.  I've done that before, and if it works for your scenario, keep using it.  Others who are just starting out will probably be pointed to NI Packages as a means of distribution.  I won't go into the detail, but power users of NI Package Manager have posts and YouTube videos online of how to isolate it from the Internet and use it as a tool for hosting only your own tools on your intranet.

Regarding the Ideas Exchange:

I think it's a matter of getting the Kudos.  Top kudoed items are actually evaluated by NI and given a label of 'declined', 'accepted', 'completed', etc.  Talking about your Idea on these forums, where relevant, will draw people to see it.  When it gets to the hundreds, it gets noticed.  I've personally noticed the Ideas change status by NI about a month before the next release, depending on who is manning the helm of interacting with the community.

 

George T. of Thetic Engineering Ltd.
Consulting in the UK on Test Strategy with TestStand, LabVIEW, NI STS, PXI, and Python
0 Kudos
Message 20 of 20
(656 Views)