diff --git a/props/model-ompp.4.build.targets b/props/model-ompp.4.build.targets
index b51d5a98d..6ecc51815 100644
--- a/props/model-ompp.4.build.targets
+++ b/props/model-ompp.4.build.targets
@@ -135,42 +135,6 @@
OmcCompile;$(BuildDependsOn)
-
-
-
-
-
- $([System.IO.Path]::GetFullPath('$(OM_ROOT)'))
-
-
- $([System.IO.Path]::GetFullPath('$(ProjectDir)..\..\..'))
- $([MSBuild]::MakeRelative($(ABS_OM_ROOT), $(PUBLISH_DIR)))
- $(PUBLISH_DIR)/$(MODEL_NAME).oms_url.tickle
- $(PUBLISH_DIR_REL_TO_OM_ROOT)/$(MODEL_NAME).oms_url.tickle
- $(PUBLISH_DIR_REL_TO_OM_ROOT)/$(MODEL_NAME).stop_oms.log
-
-
-
-
-
-
-
-
-
-
-
-
@@ -330,7 +294,6 @@
ContinueOnError="true"/>
-
@@ -342,26 +305,31 @@
Template files are located in OM_ROOT/etc directory
-->
- $(PUBLISH_DIR_REL_TO_OM_ROOT)/$(MODEL_NAME).start_ompp_ui.log
run.Debug.template.txt
run.Debug.template.txt
$(OM_CFG_DEFAULT_RUN_TMPL)
+ $(PUBLISH_DIR)/$(MODEL_NAME).oms_url.tickle
+ $([System.IO.Path]::GetFullPath('$(OM_ROOT)'))
+
+
+ $([System.IO.Path]::GetFullPath('$(ProjectDir)..\..\..'))
+ "$(ABS_OM_ROOT)\props\start-ui-at-build.bat"
-
+
diff --git a/props/start-ompp-ui.bat b/props/start-ompp-ui.bat
index 6c8a8e91e..55623418a 100644
--- a/props/start-ompp-ui.bat
+++ b/props/start-ompp-ui.bat
@@ -117,10 +117,26 @@ mkdir "%PUBLISH_DIR%\io\download"
mkdir "%PUBLISH_DIR%\io\upload"
cd .
-REM start oms web-service and UI
+REM delete oms URL file if exist
+
+set OMS_URL_TICKLE=%MODEL_NAME%.oms_url.tickle
+
+REM @echo OMS_URL_TICKLE = %OMS_URL_TICKLE%
+
+if exist "%OMS_URL_TICKLE%" (
+
+ del /q %OMS_URL_TICKLE%
+ if ERRORLEVEL 1 (
+ @echo FAIL to delete: %OMS_URL_TICKLE%
+ EXIT 1
+ )
+)
+if exist "%OMS_URL_TICKLE%" (
+ @echo FAIL to delete: %OMS_URL_TICKLE%
+ EXIT 1
+)
-set OMS_URL_TICKLE=%PUBLISH_DIR%\%MODEL_NAME%.oms_url.tickle
-rem set START_OMPP_UI_LOG=%PUBLISH_DIR%\%MODEL_NAME%.start_ompp_ui.log
+REM start oms web-service and UI
set OM_CFG_INI_ALLOW=true
set OM_CFG_INI_ANY_KEY=true
@@ -135,10 +151,14 @@ timeout /T 2 /nobreak >nul
REM read oms url from file and open browser
-for /F "usebackq tokens=* delims=" %%i in ("%OMS_URL_TICKLE%") do (
+if not exist "%OMS_URL_TICKLE%" (
+ @echo ERROR: oms start failed, URL file not found: %OMS_URL_TICKLE%
+ EXIT 1
+)
+
+for /F "usebackq tokens=* delims=" %%i in (%OMS_URL_TICKLE%) do (
set OMS_URL=%%i
)
@echo Starting openM++ UI at: %OMS_URL%
START %OMS_URL%
-
diff --git a/props/start-ui-at-build.bat b/props/start-ui-at-build.bat
new file mode 100644
index 000000000..dff1f6dba
--- /dev/null
+++ b/props/start-ui-at-build.bat
@@ -0,0 +1,127 @@
+@echo off
+
+REM Windows: start openM++ UI from model/ompp/bin directory
+REM
+REM Environment:
+REM
+REM MODEL_NAME: model name, default: current directory name
+REM
+REM OM_ROOT: openM++ root folder, default: ..\..
+REM
+REM OM_CFG_DEFAULT_RUN_TMPL: if defined then UI configured to use this model run template, by default
+REM if Release model.exe not exist and Debug modelD.exe exist then: run.Debug.template.txt
+REM
+
+setlocal enabledelayedexpansion
+
+REM check MODEL_NAME and OM_ROOT environment
+
+IF "%MODEL_NAME%" == "" (
+ @echo ERROR: empty MODEL_NAME environment variable
+ EXIT 1
+)
+@echo MODEL_NAME = %MODEL_NAME%
+
+IF "%OM_ROOT%" == "" (
+ @echo ERROR: empty OM_ROOT environment variable
+ EXIT 1
+)
+@echo OM_ROOT = %OM_ROOT%
+
+if not exist "%OM_ROOT%\html" (
+ @echo ERROR: missing UI html directory: %OM_ROOT%\html
+ EXIT 1
+)
+if not exist "%OM_ROOT%\bin\oms.exe" (
+ @echo ERROR: missing openM++ web-service: %OM_ROOT%\bin\oms.exe
+ EXIT 1
+)
+if not exist "%OM_ROOT%\bin\dbcopy.exe" (
+ @echo ERROR: missing openM++ dbcopy utility: %OM_ROOT%\bin\dbcopy.exe
+ EXIT 1
+)
+
+REM check if model.exe exist and model.sqlite exist
+REM if only Debug modelD.exe exist then set model run template to run.Debug.template.txt
+
+if exist "%MODEL_NAME%.exe" (
+ set model_exe_name=%MODEL_NAME%.exe
+)
+if not defined model_exe_name (
+ if exist "%MODEL_NAME%D.exe" (
+
+ set model_exe_name=%MODEL_NAME%D.exe
+
+ if not defined OM_CFG_DEFAULT_RUN_TMPL (
+ set OM_CFG_DEFAULT_RUN_TMPL=run.Debug.template.txt
+ )
+ )
+)
+if not defined model_exe_name (
+ @echo ERROR: %MODEL_NAME% exe not found
+ EXIT 1
+)
+
+if not exist "%MODEL_NAME%.sqlite" (
+ @echo ERROR: model SQLite database not found: %MODEL_NAME%.sqlite
+ EXIT 1
+)
+
+REM create directories for download and upload from UI, errors are not critical and can be ignored
+
+mkdir "io\download"
+mkdir "io\upload"
+cd .
+
+REM delete oms URL file if exist
+
+set OMS_URL_TICKLE=%MODEL_NAME%.oms_url.tickle
+
+REM @echo OMS_URL_TICKLE = %OMS_URL_TICKLE%
+
+if exist "%OMS_URL_TICKLE%" (
+
+ del /q %OMS_URL_TICKLE%
+ if ERRORLEVEL 1 (
+ @echo FAIL to delete: %OMS_URL_TICKLE%
+ EXIT 1
+ )
+)
+if exist "%OMS_URL_TICKLE%" (
+ @echo FAIL to delete: %OMS_URL_TICKLE%
+ EXIT 1
+)
+
+REM start oms web-service and UI
+
+set OM_CFG_INI_ALLOW=true
+set OM_CFG_INI_ANY_KEY=true
+
+REM set OM_ModelName=/path/to/model/dir
+
+set model_root_name=OM_%MODEL_NAME%
+set %model_root_name%="%CD%"
+
+REM @echo %model_root_name% = %CD%
+
+START "oms" "%OM_ROOT%"\bin\oms.exe -l localhost:0 -oms.ModelDir ..\bin -oms.ModelLogDir ..\bin -oms.UrlSaveTo %OMS_URL_TICKLE% -oms.HtmlDir "%OM_ROOT%\html" -oms.EtcDir "%OM_ROOT%\etc" -oms.HomeDir ..\bin -oms.AllowDownload -oms.AllowUpload -oms.AllowMicrodata -oms.LogRequest -OpenM.LogToFile
+if ERRORLEVEL 1 (
+ @echo FAILED to start %OM_ROOT%\bin\oms.exe
+ EXIT 1
+)
+
+START /wait timeout /T 2 /nobreak >nul
+
+REM read oms url from file and open browser
+
+if not exist "%OMS_URL_TICKLE%" (
+ @echo ERROR: oms start failed, URL file not found: %OMS_URL_TICKLE%
+ EXIT 1
+)
+
+for /F "usebackq tokens=* delims=" %%i in (%OMS_URL_TICKLE%) do (
+ set OMS_URL=%%i
+)
+@echo Starting openM++ UI at: %OMS_URL%
+
+START %OMS_URL%
diff --git a/props/startOmppUI.ps1 b/props/startOmppUI.ps1
deleted file mode 100644
index 6950ffe39..000000000
--- a/props/startOmppUI.ps1
+++ /dev/null
@@ -1,37 +0,0 @@
-# Start openM++ UI:
-# start oms web-service listen on localhost:free_tcp_port
-# open default browser with http://localhost:free_tcp_port
-#
-$publish_dir = "$env:PUBLISH_DIR"
-$oms_url_tickle = "$env:OMS_URL_TICKLE"
-$start_ompp_ui_log = "$env:START_OMPP_UI_LOG"
-
-# create directories for download and upload from UI, errors are not critical and can be ignored
-#
-$null = New-Item -Path "$publish_dir\io\download" -ItemType Directory -ea 0
-$null = New-Item -Path "$publish_dir\io\upload" -ItemType Directory -ea 0
-
-if (!"$env:OM_ROOT") {
- $env:OM_ROOT = Resolve-Path -Path "$publish_dir/../../../.."
- Write-Host "OM_ROOT: $env:OM_ROOT"
-}
-$env:OM_CFG_INI_ALLOW = "true"
-$env:OM_CFG_INI_ANY_KEY = "true"
-
-"Start-Process bin/oms.exe -PassThru -WindowStyle Minimized -ArgumentList ""-l localhost:0 -oms.ModelDir ""$publish_dir"" -oms.ModelLogDir ""$publish_dir"" -oms.UrlSaveTo ""$oms_url_tickle"" -oms.HomeDir ""$publish_dir"" -oms.AllowDownload -oms.AllowUpload -oms.AllowMicrodata -oms.LogRequest""" | Out-File -FilePath $start_ompp_ui_log
-
-$oms_proc = Start-Process bin/oms.exe -PassThru -WindowStyle Minimized -ArgumentList "-l localhost:0 -oms.ModelDir ""$publish_dir"" -oms.ModelLogDir ""$publish_dir"" -oms.UrlSaveTo ""$oms_url_tickle"" -oms.HomeDir ""$publish_dir"" -oms.AllowDownload -oms.AllowUpload -oms.AllowMicrodata -oms.LogRequest"
-
-Start-Sleep -s 1
-
-if (!$oms_proc -or $oms_proc.ExitCode -ne $null) {
- Write-Host "Failed to start oms web-service"
- exit 1
-}
-
-($oms_url = Get-Content -TotalCount 1 -Path $oms_url_tickle) | Out-File -Append -FilePath $start_ompp_ui_log
-
-"Starting openM++ UI: $oms_url" | Out-File -Append -FilePath $start_ompp_ui_log
-Write-Host "Starting openM++ UI: $oms_url"
-
-start $oms_url
diff --git a/props/stopOms.ps1 b/props/stopOms.ps1
deleted file mode 100644
index f65f493de..000000000
--- a/props/stopOms.ps1
+++ /dev/null
@@ -1,27 +0,0 @@
-# Stop oms web-service if it MODEL_NAME.oms_url.tickle contains oms URL
-#
-$oms_url_tickle = "$env:OMS_URL_TICKLE"
-$stop_oms_log = "$env:STOP_OMS_LOG"
-
-($oms_url = Get-Content -TotalCount 1 -Path $oms_url_tickle) | Out-File -FilePath $stop_oms_log
-
-@"
-Stop oms web-service:
-
-If error is:
- 'Unable to connect to the remote server'
- then oms web-service not running on $oms_url
-If error is:
- 'The underlying connection was closed: An unexpected error occurred on a receive'
- then oms web-service shutdown succeeded
-
-"@ | Out-File -Append -FilePath $stop_oms_log
-
-Write-Host "Stop oms web-service: $oms_url"
-
-$oms_shutdown_url = "$oms_url/api/admin/shutdown"
-try {
- Invoke-WebRequest -Method PUT -Uri $oms_shutdown_url | Out-File -Append -FilePath $stop_oms_log
-} catch {
- $_ | Out-File -Append -FilePath $stop_oms_log
-}