Link to home
Start Free TrialLog in
Avatar of Luis Diaz
Luis DiazFlag for Colombia

asked on

Windows Batch & PowerShell: execute javaws with a modular approach

Hello experts,

Following command allows me to run a jnlp file located at editor site:

C:\Program Files\Java\jre1.8.0_131\bin\javaws.exe "http://applicationenvironment.com/WebStart.jnlp"

Open in new window


I have to access to multiple WebStart.jnlp for different applications related to different environments such as: testing, development, qualification, production etc.

I was wondering if there is a way to centralize everything  through a single .bat with a dual modular approach:

The required sequence is the following:

1-Prompt:
echo Enter the application that you want to access

echo. 1: for Application 1
echo. 2: for Application 2
echo. 3 : for Application 3
echo. 4 : for Application 4

2-Second prompt based on application enter:

echo Enter the environment
echo. T: for testing (url%urltesting%)
echo. D: for development (url%urldevelopment%)
echo. Q : for qualification (%urlqualification%)
echo. P : for production (%urlproduction%)

2-execute the command based on option selected.

If dual modularization is complicated I will do it 4 bats for each application and I will be happy with a single environment modular approach.

Note:
-Application 1 have 4 environments,
-Application 2 and 3: 2 environments
-Application 4: 1 environment

If you have questions, please contact me.

Thank you for your help.
Avatar of oBdA
oBdA

Is PowerShell an option here as well (could be wrapped into a batch file)?
In batch you could do something like this.  But I wasn't sure what to do based on the application selection, how does that affect the command you need to execute?  Also, I have the java execution with an ECHO in front of it for ease of testing.   See what you think.

@echo off
setlocal EnableDelayedExpansion

rem Define urls for each environment
Set UrlTesting=http://testing.com/WebStart.jnlp
Set UrlDevelopment=http://development.com/WebStart.jnlp
Set UrlQualification=http://qualification.com/WebStart.jnlp
Set UrlProduction=http://production.com/WebStart.jnlp

rem Select application, exit if blank
echo.
echo Enter the application that you want to access:
echo.  1 : Application A
echo.  2 : Application B
echo.  3 : Application C
echo.  4 : Application D
set "App="
set /p "App=Selection (1, 2, 3, 4)? "
if "%App%" EQU "" exit /b

rem Validate and set application based on selection
set "AppRef="
if "%App%" EQU "1" set AppRef=AAA
if "%App%" EQU "2" set AppRef=BBB
if "%App%" EQU "3" set AppRef=CCC
if "%App%" EQU "4" set AppRef=DDD
if "%AppRef%" EQU "" (
    echo Invalid selection
    exit /b
)

rem Select destination location mode, exit if blank
echo.
echo Enter the environment:
echo. T : for Testing
echo. D : for Development
echo. Q : for Qualification
echo. P : for Production
set "Env="
set /p "Env=Selection (T, D, Q, P)? "
if "%Env%" EQU "" exit /b

rem Validate and set environment based on selection
set "EnvRef="
if /i "%Env%" EQU "T" set EnvRef=%UrlTesting%
if /i "%Env%" EQU "D" set EnvRef=%UrlDevelopment%
if /i "%Env%" EQU "Q" set EnvRef=%UrlQualification%
if /i "%Env%" EQU "P" set EnvRef=%UrlProduction%
if "%EnvRef%" EQU "" (
    echo Invalid selection
    exit /b
)

rem For testing display values
ECHO AppRef=%AppRef%
ECHO EnvRef=%EnvRef%

rem Execute java
ECHO "C:\Program Files\Java\jre1.8.0_131\bin\javaws.exe" "%EnvRef%"

Open in new window


»bp
A slightly shorter version...

@echo off
setlocal EnableDelayedExpansion

rem Define urls for each environment
Set EnvT=http://testing.com/WebStart.jnlp
Set EnvD=http://development.com/WebStart.jnlp
Set EnvQ=http://qualification.com/WebStart.jnlp
Set EnvP=http://production.com/WebStart.jnlp

rem Define app info for each environment
Set App1=AAA
Set App2=BBB
Set App3=CCC
Set App4=DDD

rem Select application, exit if blank
echo.
echo Enter the application that you want to access:
echo.  1 : Application A
echo.  2 : Application B
echo.  3 : Application C
echo.  4 : Application D
set "App="
set /p "App=Selection (1, 2, 3, 4)? "
if "%App%" EQU "" exit /b

rem Validate and set application based on selection
set "AppRef="
if defined App%App% set AppRef=!App%App%!
if "%AppRef%" EQU "" (
    echo Invalid selection
    exit /b
)

rem Select destination location mode, exit if blank
echo.
echo Enter the environment:
echo. T : for Testing
echo. D : for Development
echo. Q : for Qualification
echo. P : for Production
set "Env="
set /p "Env=Selection (T, D, Q, P)? "
if "%Env%" EQU "" exit /b

rem Validate and set environment based on selection
set "EnvRef="
if defined Env%Env% set EnvRef=!Env%Env%!
if "%EnvRef%" EQU "" (
    echo Invalid selection
    exit /b
)

rem For testing display values
ECHO AppRef=%AppRef%
ECHO EnvRef=%EnvRef%

rem Execute java
ECHO "C:\Program Files\Java\jre1.8.0_131\bin\javaws.exe" "%EnvRef%"

Open in new window


»bp
For the fun of it, a PowerShell solution.
You just need to define the menu in the XML; should be pretty self-explanatory. The environment menu will only show the selections enabled for the app selected previously.
It uses the built-in selection dialog, which first shows the options in a single line; you can select an option immediately, or enter ? to get a full menu including the helpMessage.
Start-Process in line 43 is commented out for testing.
## "^" marks the character to use as hotkey; if no hotkey is defined, a numeric index will be auto-created.
$menu = [xml]@'
	<menu>
		<appStrings caption="Welcome" message="Enter the application that you want to access" />
		<envStrings caption="" message="Enter the environment" />
		<apps>
			<app label="Application ^1" helpMessage="Start Application 1" envIds="1, 2, 3, 4" />
			<app label="Application ^2" helpMessage="Start Application 2" envIds="2, 3" />
			<app label="Application ^3" helpMessage="Start Application 3" envIds="1, 4" />
			<app label="Application ^4" helpMessage="Start Application 4" envIds="4" />
		</apps>
		<envs>
			<env id="1" label="^Testing" helpMessage="Testing environment" url="http://testing.com/WebStart.jnlp" />
			<env id="2" label="^Development" helpMessage="Development environment" url="http://development.com/WebStart.jnlp" />
			<env id="3" label="^Qualification" helpMessage="Qualification environment" url="http://qualification.com/WebStart.jnlp" />
			<env id="4" label="^Production" helpMessage="Production environment" url="http://production.com/WebStart.jnlp" />
		</envs>
		<exit label="e^Xit" helpMessage="Leave without starting an application" />
	</menu>
'@

$appStrings = $menu.SelectNodes('menu/appStrings')
$envStrings = $menu.SelectNodes('menu/envStrings')
$appNodes = $menu.SelectNodes('menu/apps/app')
$choices = @($appNodes + $menu.SelectNodes('menu/exit')) | ForEach-Object {
	New-Object -TypeName System.Management.Automation.Host.ChoiceDescription -ArgumentList $_.GetAttribute('label').Replace('^', '&'), $_.GetAttribute('helpMessage')
}
$answer = $host.UI.PromptForChoice($appStrings.GetAttribute('caption'), $appStrings.GetAttribute('message'), $choices, ($choices.Count - 1))
If ($answer -eq $choices.Count - 1) {
	Write-Host 'Goodbye'
} Else {
	$envIds = $appNodes[$answer].GetAttribute('envIds').Split(',').Trim()
	$envNodes = @($menu.SelectNodes('menu/envs/env') | Where-Object {$envIds -contains $_.GetAttribute('id')})
	$choices = @($envNodes + $menu.SelectNodes('menu/exit')) | ForEach-Object {
		New-Object -TypeName System.Management.Automation.Host.ChoiceDescription -ArgumentList $_.GetAttribute('label').Replace('^', '&'), $_.GetAttribute('helpMessage')
	}
	$answer = $host.UI.PromptForChoice($envStrings.GetAttribute('caption'), $envStrings.GetAttribute('message'), $choices, ($choices.Count - 1))
	If ($answer -eq $choices.Count - 1) {
		Write-Host 'Goodbye'
	} Else {
		$url = $envNodes[$answer].GetAttribute('url')
		Write-Host "`r`nStarting '$($url)'"
		# Start-Process -FilePath 'C:\Program Files\Java\jre1.8.0_131\bin\javaws.exe' -ArgumentList $url
	}
}

Open in new window

Avatar of Luis Diaz

ASKER

Sorry for the delay. Powershell and Windows Batch are more than welcome. I will test them and let you know.
I see from the PS solution what I was missing on the application filtering the number of environments.  I'll work up an adjusted version...

»bp
Just one note that I think that I missed in the spec. Sorry for this.
Editor modulation should be specify on each url.
Based on this we need to have a modulation by URL like this:
Editor 1:
http://production-editor1.com
http://qualification-editor1.com
http://development-editor1.com
http://testing-editor1.com
[b]Editor 2:[/b]
http://production-editor2.com
http://testing-editor2.com
Editor 3:
http://production-editor3.com
http://production-editor3.com
Editor4:
http://production-editor4.com





editor = application number?

»bp
I'm not quite sure I'm following.
Is the URL made up basically as "<Environment>-<Application>"?
And for "Editor 3", you have this; is this intentional?
http://production-editor3.com
http://production-editor4.com
And, was this a mistake / typo, I wasn't expecting multiples of the same environment in an application?
Editor 3:
http://production-editor3.com
http://production-editor4.com

»bp
Typo mistake concerning Editor 3, I edited my previous comment:

Concerning the modulation:
Editor 1:
4 urls
Editor 2:
2 urls
Editor 3
2 urls
Editor 4
1 url.

The editor is reported as a suffix in the url.
That's too vague.
Again: Is the URL made up basically as "<Environment>-<Application>"?
What is the exact format of the URL in relation to the the application and the environment selected?
Okay, making some guesses about what you truly want, see if this lines up with the needs.

***** EXAMPLE EXECUTION *****

Enter the application that you want to access:
  1 : Application 1
  2 : Application 2
  3 : Application 3
  4 : Application 4
Selection (1,2,3,4)? 2

Enter the environment that you want to access:
  T : Testing
  P : Development
Selection (T,P)? p

"C:\Program Files\Java\jre1.8.0_131\bin\javaws.exe" "http://production-editor2.com/WebStart.jnlp"

Open in new window


***** SCRIPT CODE *****

@echo off
setlocal EnableDelayedExpansion

rem Define vars for application selection
set AppsHeader=Enter the application that you want to access:
set AppsList=1,2,3,4
set AppsText1=Application 1
set AppsText2=Application 2
set AppsText3=Application 3
set AppsText4=Application 4

rem Define vars for environment selection (for application 1)
set Env1Header=Enter the environment that you want to access:
set Env1List=T,D,Q,P
set Env1TextT=Testing
set Env1TextD=Development
set Env1TextQ=Qualification
set Env1TextP=Production

rem Define vars for environment selection (for application 2)
set Env2Header=Enter the environment that you want to access:
set Env2List=T,P
set Env2TextT=Testing
set Env2TextP=Development

rem Define vars for environment selection (for application 3)
set Env3Header=Enter the environment that you want to access:
set Env3List=Q,P
set Env3TextQ=Qualification
set Env3TextP=Production

rem Define vars for environment selection (for application 4)
set Env4Header=Enter the environment that you want to access:
set Env4List=P
set Env4TextP=Production

rem Define mapping from environment letter to full name (used in URL)
set EnvMapT=testing
set EnvMapD=development
set EnvMapQ=qualification
set EnvMapP=production

rem Prompt for application number
echo.
call :Select "Apps"
set App=%AppsChoice%

rem Prompt for environment letter
echo.
call :Select "Env%App%"
set Env=!Env%App%Choice!

rem Build URL from responses
set URL=http://!EnvMap%Env%!-editor%App%.com/WebStart.jnlp

rem Launch java module
echo.
echo "C:\Program Files\Java\jre1.8.0_131\bin\javaws.exe" "%URL%"

exit /b

rem Subroutine to display a selection list and validate and return response
:Select [var-name-prefice]
    echo !%~1Header!
    for %%a in (!%~1List!) do (
        echo.  %%a : !%~1Text%%a!
    )
    set /p "_p=Selection (!%~1List!)? "
    if defined %~1Text%_p% (
        set %~1Choice=%_p%
    ) else (
        set %~1Choice=
    )
    exit /b

Open in new window


»bp
Changed the XML format so you can define the url component for the app and the environment.
And feel free as well to customize the ids that join the app to the env.
## "^" marks the character to use as hotkey; if no hotkey is defined, a numeric index will be auto-created.
$menu = [xml]@'
	<menu>
		<appStrings caption="Welcome" message="Select the application that you want to access:" />
		<envStrings caption="" message="Select the environment:" />
		<apps>
			<app label="Application ^1" helpMessage="Start Application 1" urlComponent="editor1" envIds="tst, dev, qua, prd" />
			<app label="Application ^2" helpMessage="Start Application 2" urlComponent="editor2" envIds="tst, prd" />
			<app label="Application ^3" helpMessage="Start Application 3" urlComponent="editor3" envIds="tst, prd" />
			<app label="Application ^4" helpMessage="Start Application 4" urlComponent="editor4" envIds="prd" />
		</apps>
		<envs>
			<env id="tst" label="^Testing" helpMessage="Testing environment" urlComponent="testing" />
			<env id="dev" label="^Development" helpMessage="Development environment" urlComponent="development" />
			<env id="qua" label="^Qualification" helpMessage="Qualification environment" urlComponent="qualification" />
			<env id="prd" label="^Production" helpMessage="Production environment" urlComponent="production" />
		</envs>
		<exit label="e^Xit" helpMessage="Leave without starting an application" />
	</menu>
'@

$appStrings = $menu.SelectNodes('menu/appStrings')
$envStrings = $menu.SelectNodes('menu/envStrings')
$appNodes = $menu.SelectNodes('menu/apps/app')
$choices = @($appNodes + $menu.SelectNodes('menu/exit')) | ForEach-Object {
	New-Object -TypeName System.Management.Automation.Host.ChoiceDescription -ArgumentList $_.GetAttribute('label').Replace('^', '&'), $_.GetAttribute('helpMessage')
}
$appAnswer = $host.UI.PromptForChoice($appStrings.GetAttribute('caption'), $appStrings.GetAttribute('message'), $choices, ($choices.Count - 1))
If ($appAnswer -eq $choices.Count - 1) {
	Write-Host 'Goodbye'
} Else {
	$envIds = $appNodes[$appAnswer].GetAttribute('envIds').Split(',').Trim()
	$envNodes = @($menu.SelectNodes('menu/envs/env') | Where-Object {$envIds -contains $_.GetAttribute('id')})
	$choices = @($envNodes + $menu.SelectNodes('menu/exit')) | ForEach-Object {
		New-Object -TypeName System.Management.Automation.Host.ChoiceDescription -ArgumentList $_.GetAttribute('label').Replace('^', '&'), $_.GetAttribute('helpMessage')
	}
	$envAnswer = $host.UI.PromptForChoice($envStrings.GetAttribute('caption'), $envStrings.GetAttribute('message'), $choices, ($choices.Count - 1))
	If ($envAnswer -eq $choices.Count - 1) {
		Write-Host 'Goodbye'
	} Else {
		$url = 'http://' + $envNodes[$envAnswer].GetAttribute('urlComponent') + '-' + $appNodes[$appAnswer].GetAttribute('urlComponent') + '.com'
		Write-Host "`r`nStarting '$($url)'"
		# Start-Process -FilePath 'C:\Program Files\Java\jre1.8.0_131\bin\javaws.exe' -ArgumentList $url
	}
}

Open in new window

Sample run:
Welcome
Select the application that you want to access:
[1] Application 1  [2] Application 2  [3] Application 3  [4] Application 4  [X] eXit  [?] Help (default is "X"): 1
Select the environment:
[T] Testing  [D] Development  [Q] Qualification  [P] Production  [X] eXit  [?] Help (default is "X"): ?
T - Testing environment
D - Development environment
Q - Qualification environment
P - Production environment
X - Leave without starting an application
[T] Testing  [D] Development  [Q] Qualification  [P] Production  [X] eXit  [?] Help (default is "X"): p

Starting 'http://production-editor1.com'

Open in new window

Thank you very much for those proposals. I noticed that the split/drill down editor>environment was not clear and to bring another complexity I don't have always the url structure http://editor-environnent.com. sometimes I have http://environnent.editor.com  With this in mind I realized that the straight forward approach is to have a single prompt selection with the 9 url and based on on the value selected call the Java command. I am really sorry for this change. If this is a problem I will try to adapt proposals alreay posted.

Example of sequence: please enter 1 for editorurl , 2 foreditorurl, 3 for... And so one.
Luis,

I'd ask that you "start over" and restate the requirements as completely and accurately as you can at this point before I/we try another attempt.

Share how many times the use will be prompted, what the title should be for that prompt, what the choices should be, and what the "results" of the various choices mean.  List all the URLs that are needed and how the input correlates to them.

Etc...


»bp
You should still be able to drill down; this defines the environment selection separately for each app:
## "^" marks the character to use as hotkey; if no hotkey is defined, a numeric index will be auto-created.
$menu = [xml]@'
	<menu>
		<appStrings caption="Welcome" message="Select the application that you want to access:" />
		<envStrings caption="" message="Select the environment:" />
		<app label="Application ^1" helpMessage="Start Application 1">
			<env label="^Testing" helpMessage="Testing environment" urlComponent="testing.app1" />
			<env label="^Development" helpMessage="Development environment" urlComponent="development.app1" />
			<env label="^Qualification" helpMessage="Qualification environment" urlComponent="qualification.app1" />
			<env label="^Production" helpMessage="Production environment" urlComponent="production.app1" />
		</app>
		<app label="Application ^2" helpMessage="Start Application 2">
			<env label="^Testing" helpMessage="Testing environment" urlComponent="testing.app2" />
			<env label="^Production" helpMessage="Production environment" urlComponent="production.app2" />
		</app>
		<app label="Application ^3" helpMessage="Start Application 3">
			<env label="^Testing" helpMessage="Testing environment" urlComponent="testing.app3" />
			<env label="^Production" helpMessage="Production environment" urlComponent="production.app3" />
		</app>
		<app label="Application ^4" helpMessage="Start Application 4">
			<env label="^Production" helpMessage="Production environment" urlComponent="production.app4" />
		</app>
		<exit label="e^Xit" helpMessage="Leave without starting an application" />
	</menu>
'@

$appStrings = $menu.SelectSingleNode('menu/appStrings')
$envStrings = $menu.SelectSingleNode('menu/envStrings')
$appNodes = $menu.SelectNodes('menu/app')
$choices = @($appNodes + $menu.SelectSingleNode('menu/exit')) | ForEach-Object {
	New-Object -TypeName System.Management.Automation.Host.ChoiceDescription -ArgumentList $_.GetAttribute('label').Replace('^', '&'), $_.GetAttribute('helpMessage')
}
$appAnswer = $host.UI.PromptForChoice($appStrings.GetAttribute('caption'), $appStrings.GetAttribute('message'), $choices, ($choices.Count - 1))
If ($appAnswer -eq $choices.Count - 1) {
	Write-Host 'Goodbye'
} Else {
	$envNodes = $appNodes[$appAnswer].SelectNodes('env')
	$choices = @($envNodes + $menu.SelectSingleNode('menu/exit')) | ForEach-Object {
		New-Object -TypeName System.Management.Automation.Host.ChoiceDescription -ArgumentList $_.GetAttribute('label').Replace('^', '&'), $_.GetAttribute('helpMessage')
	}
	$envAnswer = $host.UI.PromptForChoice($envStrings.GetAttribute('caption'), $envStrings.GetAttribute('message'), $choices, ($choices.Count - 1))
	If ($envAnswer -eq $choices.Count - 1) {
		Write-Host 'Goodbye'
	} Else {
		$url = 'http://' + $envNodes[$envAnswer].GetAttribute('urlComponent') + '/WebStart.jnlp'
		Write-Host "`r`nStarting '$($url)'"
		# Start-Process -FilePath 'C:\Program Files\Java\jre1.8.0_131\bin\javaws.exe' -ArgumentList $url
	}
}

Open in new window

I know some of these choices will not be offered to the user.  But it seems like you have a grid like this of the combinations of application and environment, and you need to specify the URL's that need to be the result of each combination (I placed what my last script does currently, but it sounds like you have adjustments to that).  In addition indicate which choices should be shown to the user.  Maybe this is the easiest way to think about it...

ApplicationEnvironmentURL
1Thttp://test-editor1.com/WebStart.jnlp
1Dhttp://development-editor1.com/WebStart.jnlp
1Qhttp://qualification-editor1.com/WebStart.jnlp
1Phttp://production-editor1.com/WebStart.jnlp
2Thttp://test-editor2.com/WebStart.jnlp
2Dhttp://development-editor2.com/WebStart.jnlp
2Qhttp://qualification-editor2.com/WebStart.jnlp
2Phttp://production-editor2.com/WebStart.jnlp
3Thttp://test-editor3.com/WebStart.jnlp
3Dhttp://development-editor3.com/WebStart.jnlp
3Qhttp://qualification-editor3.com/WebStart.jnlp
3Phttp://production-editor3.com/WebStart.jnlp
4Thttp://test-editor4.com/WebStart.jnlp
4Dhttp://development-editor4.com/WebStart.jnlp
4Qhttp://qualification-editor4.com/WebStart.jnlp
4Phttp://production-editor4.com/WebStart.jnlp


xxxxxxxxxxxxxxxx
I reviewed again the urls and unfortunately I couldn't find a common key.
Some of them have DevEditor other TEditor other TestEditor. This is the big disadvantage and difficulty when you work with different editors and they apply different rules.

Given this I have:
Editor 1:
http://url1/2048/WebStart.jnlp
http:///ur2/2048/WebStart.jnlp
http://url3/2048/WebStart.jnlp
http://url4/2048/WebStart.jnlp

Editor 2:
http://url5/2048/WebStart.jnlp
http://url6/2048/WebStart.jnlp

Editor 3:
http://url7/2048/WebStart.jnlp
http://url8/2048/WebStart.jnlp

Editor 4:
http://url9/2048/WebStart.jnlp

Only common element is the string: 2048/WebStart.jnlp

The only process that can cover this is the following:

First sequence
Select the editor, Enter 1 for editor1, 2 for editor2, 3 for editor3, 4 for editor4
I enter 1
Please enter one of the 4 choice related to editor1
For Production enter P (%url1%) "http://url1/2048/WebStart.jnlp"
For Qualification enter Q (%url2%) "http://url2/2048/WebStart.jnlp"
For Development enter D (%url3%) "http://url3/2048/WebStart.jnlp"
For Testing enter T (%url4%) "http://url4/2048/WebStart.jnlp"
Note: the best is to display the full url to make the relation when I have the prompt and do the right choice
I enter T
I should have:
C:\Program Files\Java\jre1.8.0_131\bin\javaws.exe" "%url4%"

Second sequence
Select the editor, Enter 1 for editor1, 2 for editor2, 3 for editor3, 4 for for editor4
I enter 3
Please enter one of the 3 choice related to editor 1
For Production enter P (%url7%) "http://url7/2048/WebStart.jnlp"
For Development enter D (%url8%) "http://url8/2048/WebStart.jnlp"
I enter T
I should have:
C:\Program Files\Java\jre1.8.0_131\bin\javaws.exe" "%url8%"

Another approach and due to the complexity of urls definition is to have it without drill down

Sequence 1
Single prompt:
Enter 1 for: Editor 1 Production "http://url1/2048/WebStart.jnlp"
Enter 2 for: Editor 1 Qualification "http://url2/2048/WebStart.jnlp"
Enter 3 for: Editor 1 Development "http://url3/2048/WebStart.jnlp"
Enter 4 for: Editor 1 Testing "http://url4/2048/WebStart.jnlp"
Enter 5 for: Editor 2 Production "http://url5/2048/WebStart.jnlp"
Enter 6 for: Editor 2 Testing "http://url6/2048/WebStart.jnlp"
Enter 7 for: Editor 3 Production "http://url7/2048/WebStart.jnlp"
Enter 8 for: Editor 3 Development "http://url8/2048/WebStart.jnlp"
Enter 9 for: Editor 4  Production "http://url9/2048/WebStart.jnlp"
I enter 6
I should have:
C:\Program Files\Java\jre1.8.0_131\bin\javaws.exe" "%url6%"

I am really sorry for this. If you prefer that I create a new question and validate your proposals I will do it.
Let me know if one the proposal already posted cover 1 of the approaches and I will try to test them.

Regards,
Luis.
It’s fine if there isn’t a simple pattern to the urls.  just add each one to the URL column in the table I posted above and I can take it from there.
That's basically all already covered above. It's not really complex, it just makes for more entries.
All you have to do is fill in the urlComponent (this is the functional relevant part, that is, the string between "http://" and "/2048/..."), and the label and helpMessage (used for display only, change to whatever suits you).
You can add more <app> or <env> nodes following the pattern, you can remove them, you can reorder them, you can give the editors more descriptive names, whatever.
Only change to the functionality above is that this will now display the url in the "full" menu if you want to verify the target.
## "^" marks the character to use as hotkey; if no hotkey is defined, a numeric index will be auto-created.
$menu = [xml]@'
	<menu>
		<appStrings caption="Welcome" message="Select the Editor you want to use:" />
		<envStrings caption="" message="Select the environment:" />
		<app label="Editor ^1" helpMessage="Start Editor 1">
			<env label="^Production" helpMessage="Production" urlComponent="production.app1" />
			<env label="^Qualification" helpMessage="Qualification" urlComponent="qualification.app1" />
			<env label="^Development" helpMessage="Development" urlComponent="development.app1" />
			<env label="^Testing" helpMessage="Testing" urlComponent="testing.app1" />
		</app>
		<app label="Editor ^2" helpMessage="Start Editor 2">
			<env label="^Production" helpMessage="Production" urlComponent="production.app2" />
			<env label="^Testing" helpMessage="Testing" urlComponent="testing.app2" />
		</app>
		<app label="Editor ^3" helpMessage="Start Editor 3">
			<env label="^Production" helpMessage="Production" urlComponent="production.app3" />
			<env label="^Development" helpMessage="Development" urlComponent="development.app3" />
		</app>
		<app label="Editor ^4" helpMessage="Start Editor 4">
			<env label="^Production" helpMessage="Production" urlComponent="production.app4" />
		</app>
		<exit label="e^Xit" helpMessage="Leave without starting an editor" />
	</menu>
'@

$appStrings = $menu.SelectSingleNode('menu/appStrings')
$envStrings = $menu.SelectSingleNode('menu/envStrings')
$appNodes = $menu.SelectNodes('menu/app')
$choices = @($appNodes + $menu.SelectSingleNode('menu/exit')) | ForEach-Object {
	New-Object -TypeName System.Management.Automation.Host.ChoiceDescription -ArgumentList $_.GetAttribute('label').Replace('^', '&'), $_.GetAttribute('helpMessage')
}
$appAnswer = $host.UI.PromptForChoice($appStrings.GetAttribute('caption'), $appStrings.GetAttribute('message'), $choices, ($choices.Count - 1))
If ($appAnswer -eq $choices.Count - 1) {
	Write-Host 'Goodbye'
} Else {
	$envNodes = $appNodes[$appAnswer].SelectNodes('env')
	$choices = @($envNodes + $menu.SelectSingleNode('menu/exit')) | ForEach-Object {
		New-Object -TypeName System.Management.Automation.Host.ChoiceDescription -ArgumentList $_.GetAttribute('label').Replace('^', '&'), "$($_.GetAttribute('helpMessage')) ($($_.GetAttribute('urlComponent')))"
	}
	$envAnswer = $host.UI.PromptForChoice($envStrings.GetAttribute('caption'), $envStrings.GetAttribute('message'), $choices, ($choices.Count - 1))
	If ($envAnswer -eq $choices.Count - 1) {
		Write-Host 'Goodbye'
	} Else {
		$url = 'http://' + $envNodes[$envAnswer].GetAttribute('urlComponent') + '/2048/WebStart.jnlp'
		Write-Host "`r`nStarting '$($url)'"
		# Start-Process -FilePath 'C:\Program Files\Java\jre1.8.0_131\bin\javaws.exe' -ArgumentList $url
	}
}

Open in new window

Sample run:
Welcome
Select the Editor you want to use:
[1] Editor 1  [2] Editor 2  [3] Editor 3  [4] Editor 4  [X] eXit  [?] Help (default is "X"): 1
Select the environment:
[P] Production  [Q] Qualification  [D] Development  [T] Testing  [X] eXit  [?] Help (default is "X"): ?
P - Production (production.app1)
Q - Qualification (qualification.app1)
D - Development (development.app1)
T - Testing (testing.app1)
X - Leave without starting an editor ()
[P] Production  [Q] Qualification  [D] Development  [T] Testing  [X] eXit  [?] Help (default is "X"): d

Starting 'http://development.app1/2048/WebStart.jnlp'

Open in new window

@Bill: Here is the information required for Windows batch approach.
EditorEnvironmentURL
1Productionhttp://url1/2048/WebStart.jnlp
1Qualificationhttp:///ur2/2048/WebStart.jnlp
1Developmenthttp://url3/2048/WebStart.jnlp
1Testinghttp://url4/2048/WebStart.jnlp
2Productionhttp://url5/2048/WebStart.jnlp
2Testinghttp://url6/2048/WebStart.jnlp
3Productionhttp://url7/2048/WebStart.jnlp
3Developmenthttp://url8/2048/WebStart.jnlp
4Productionhttp://url9/2048/WebStart.jnlp

@oBdA: thank you very much for this proposal, I will test it and keep you informed.
@oBdA: Concerning Powershell approach I would like to see the feasibility of single approach. Is there a way to have an approach without Editor>Environment. Two information merged.
EditorEnvironment/URL1 
EditorEnvironment/URL2
EditorEnvironment/URL3 
EditorEnvironment/URL4 
EditorEnvironment/URL5
EditorEnvironment/URL6
EditorEnvironment/URL7
EditorEnvironment/URL8
EditorEnvironment/URL9
I supposed that XML should be modified with N-1 levels as the previous proposed?
SOLUTION
Avatar of oBdA
oBdA

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you very much for this proposal!
Really impressed of this GridView Powershell feature!
I will test it soon and let you know. Let's wait in the meantime Bill's proposal to have both approaches.
First test of Grid-View
User generated image]
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you very much Bill, I will test them and keep you informed.
@OBdA, I tested both approach and I was able to run 9 urls, Just 3 questions for my knowledge:
"^" #marks the character to use as hotkey; if no hotkey is defined, a numeric index will be auto-created.

Open in new window

1.You can call a Powershell Script through a hotkey? I didn't know this. If I want to do do a test with Altgr + j hotkey combination how should I proceed?
2.In order to make unavailable the GridView and XML menu, after final selection, the best practice is to put Exit at the end?
3.Since you can have a selector through XML menu, you can also have Inputbox in Powershell?
Once again, really impressed about those features in Powershell.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
@Bill, I tested both Windows batch approach and they work. Thank you again

I was wondering if there is a way to have for single prompt text everything in one command command instead of multiple lines:
With dual prompt you have everything in one blockUser generated imageWhy with single prompt you have in different lines?User generated image
Thank you oBdA for this useful comment. I take note of the inputbox in Powershell.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you very much for those useful scripts.

@Bill: concerning your last comment. You were right I retest single approach and I have in single prompt. My mistake.