Reputation: 123
I have published a ConsoleApp with VS2017 under Win10 which needs 3 Arguments on starting. I have done the setup.exe and copied the Programm-File (Con_trackTrace1.appref-ms) to C:. In CMD I tried to call it with the Parameters in different ways:
Con_trackTrace1.appref-ms argument1 argument2 argument3
Con_trackTrace1.appref-ms -argument1 -argument2 -argument3
Con_trackTrace1 argument1 argument2 argument3
Con_trackTrace1 -argument1 -argument2 -argument3
Getting:
Program not found OR Argument-Index out of Range.
Can someone tell what I´m doing wrong? In Debugging call it with CommandLine-Arguments within the Debug-Options and is running okay.
Here is the Part of taking Arguments:
static void Main(string[] args)
{
// Parameter setup-Datei
// Client_ID + Client_SECRET aus textdatei holen (1. Zeile = ClientID, 2. Zeile = ClientSECRET, 3. Zeile = pfad)
// Zugangsdaten an QA oder PROD anpassen (2 Setup-Dateien)
string[] setupDatei = null;
if (args[0] == "prod")
{
setupDatei = File.ReadAllLines("C://tracker/setupPROD.txt");
}
if (args[0] == "qa")
{
setupDatei = File.ReadAllLines("C://tracker/setupQA.txt");
}
string clientID = setupDatei[0];
string clientSECRET = setupDatei[1];
string pfad = setupDatei[2];
// Parameter Programmaufruf
// 1. Umgebung
string umgebung = args[0];
// 2. Funktion
string funktionID = args[1];
// 3. JSON-Datei (Dateiname OHNE Endung / MUSS .json sein !!!)
string jsonDateiname = args[2];
}
Upvotes: 0
Views: 114
Reputation: 123
Summary of the Basic Stuff i have learned:
Installing with setup.exe is not needed. Copying all files from the bin/Release-Folder of VS-Solution-Folder to Destination-Folder and start the Program-Exe there with Arguments.
All needed DLLs have to be in the Folder of the Exe-File.
Thanks a lot to ARCHER
Upvotes: 1