VB.NET call desktop application from 2 shortcuts - supply different parameters - vb.net

I have a desktop application which reads files from a specified folder, then deposits the files to a folder in a third party document management system based on criteria that the user provides.
My question is:
is it possible to somehow provide different parameters to the code, depending on which shortcut of the application the user clicked on to start it up?

You can add command line parameters to a shortcut icon. Here's how you can do it in Windows:
On the Start Menu, navigate to Notepad.
Right click on Notepad and choose Send To > Desktop (Create Shortcut)
Right click on the newly-created desktop icon and choose Properties
Add your command line parameters to the Target text box.
For example, if you want notepad to open up the hosts file, this would be the content of Target property:
%SystemRoot%\system32\notepad.exe "C:\WINDOWS\system32\drivers\etc\hosts"
You can put pretty much anything into the Target property of a shortcut that you would put into a command line.

Yes.
The easiest way would be to have the shortcut pass those parameters in via the command line.

You could also use conditional compilation variables, and have 2 different .exes. You should be able to find samples of both approaches (command line and conditional compilation variable) in help.

Related

Where do I add command line arguments to my command line tool project in Xcode?

I'd like to be able to pass some command line arguments to my command line tool program in Xcode. Where do I add these? I'd like to do it in the IDE rather than simply do it manually from the command line.
I've found this in the help file:
Running Your Application with Arguments
Configure a scheme with runtime arguments for your application when
you run it in Xcode. The Run action in the scheme editing dialog
determines what happens when you choose Product > Run.
From the Scheme toolbar menu, choose a scheme.
From the same menu, choose Edit Scheme to display the scheme dialog.
In the left column, select Run.
To specify runtime arguments, click Arguments and then click the Add
button.
Click OK.
Click the Run button or choose Product > Run.
Solved my problem :-)

Add options to program's right-click menu

I have a small program that reads a CSV file and outputs it in a different format.
Sometimes I want a different output format so currently I just have another version of the program compiled with slightly different code (it has no GUI, you just click on the exe and it does its job).
Is there a way I can add an option to the context menu of this program to use the different output option, perhaps by running it with a command-line argument?
I mean when right-clicking on the exe file itself, so before it is actually running.
Anything I can find when searching for answers is about editing the shell, via the registry or some other way, however I only want the option to show for this program, not every file in Windows.
Code for the command line that I would be using:
If Environment.GetCommandLineArgs.Count <> 1 Then
If Environment.GetCommandLineArgs(1) = "/output2" Then
'do stuff
End If
End If

How to Run Ada Code in GPS

In GNAT Programming Studio, how do you run the program? I see it compiled successfully, but I do not see where my program has started running. I would like to test it.
First, you have to select your Main procedure in the project properties (see the "main files" tab). You can actually choose multiple files for multiple executables.
Next, you have to build it - either by pressing F4 for the first Main File in the list, or by choosing it in the Build->Project submenu, or by choosing "build all" in the Build->Project submenu (or use the toolbar for the menu entries).
Last, you can choose, which of your Main Files to run by choosing it in the Build->Run menu, or by pressing shift+F2 for the first file in the list. Enter the parameters in the dialog and press OK.
There should be a new Tab next to the Messages panel, where all output is placed, and you can use it for input, too. You could choose to use an external terminal in the run dialog.
If you want to debug it, have a look at the Debug menu. Read the documentation for more information.
Last, you can choose, which of your Main Files to run by choosing it in the Build->Run menu, or by pressing shift+F2 for the first file in the list. Enter the parameters in the dialog and press OK.
Whatever I enter here, e.g. either the name of the project, Primes_Count or the name of what I see to be the 'executable', Primes_Count.o, it just does not run.
And I get this message output on the Messages window :
Could not locate executable on path: Primes_Count.o
I don't see why Ada is making such a big deal out of the Run step.
If there is another stage between making the .o file and a finished Ada executable, then surely it is something that the GPS system can take care of itself . . .
December.
OK now, sorted. The GPS panel governing this [ Project menu > Edit Proj Props > Main Files tab ] setting was blacked out until clicked.
Running available now and working well.
it is Project->Properties-> Main Files add your file to run. This will sort out the issue.

URL to make SSMS start and connect to a db?

It would be nice to have a bunch of reference links somewhere, that could also be used to start SSMS.
Is this possible? and get it to use an already open instance?
e.g. sqlwb -E -S Server\instance
but I'm not sure if you can do this in the form of a URL
i.e. how to make a URL run CMD
Right click on your shortcut for SSMS (or copy existing one),i.e. that thing on which you click to open SSMS.
Open Properties --> tab Shortcut.
Add options to target text box
For ex., I have:
"D:\Program Files\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\Ssms.exe" -nosplash -S localhost -d _A
to avoid splash, to connect automatically to database __A, etc.
You will get help by adding non-existent option
, pressing OK, double-click shortcut
I'm not sure you can do this in a URL directly, but you could certainly create URLs to .cmd batch files (in the form of a UNC path) which contained the relevant commands.
To make a "url" run a cmd file, format it in this way:
file:///c:\folder path\myfile.cmd
If you want to embed one of these file links in a document (like Word or email) then you may need to add angle brackets around it:
<file:///c:\folder path\myfile.cmd>
and the editor will make it into a link automatically. (alternatively you could just highlight some text, right click and create a file hyperlink using the first syntax).
Launching executables from URL is a very bad idea and a security hole. I advise to avoid doing this for many reasons.

system.diagnostic.process.start problem

Im trying to create an application launcher using vb.net. I'm trying to launch desktop shortcuts that are hidden because I want my desktop to be free of mess. Those shortcuts are created through nircmd :http://www.nirsoft.net/utils/nircmd.html
I used this code:
System.Diagnostics.Process.Start("E:\Documents and Settings\Rew\Desktop\SpeakClipboard.exe")
And it returned the error that the path specified cannot be found.
I tried launching an application in program files using this method and it worked well.
Is there a problem with shortcuts? I cannot specify the path for the file where the shortcut is linked because its a shortcut in the desktop and doesn't point to anything except the nircmd.exe that is on : F:\NIRCMD
But I also tried using this path for system.diagnostic.process.start:
F:\NIRCMD\nircmd.exe cdrom open g:
But still no luck.
If I understand correctly SpeakClipboard.exe is actually a shortcut? If so it probably has a hidden .lnk extension. So you should specify SpeakClipboard.exe.lnk or SpeakClipboard.lnk if it doesn't actually have .exe in the name.
There is a property on the ProcessStartInfo object that allows you to specify an argument.
eg your command would be "F:\NIRCMD\nircmd.exe" and the arguments would be "cdrom open g:"
Does that work?