0

I am running this batch process on Windows cmd in order to update some files on a project - since the framework doesn't allow to update a plugin I am uninstalling, cleaning up and reinstalling, but that's not related to the question.

My problem is that something on the first command, inside the ionic.cmd process, stops the entire process, even when successful. I suppose it features some kind of exit statement which halts the entire process and returns me to the cmd prompt without running next files.

I have tried to change that command by some bus-process embedding like START cmd /K ... and so, with no success. So, how can I batch run that command without the whole script stopping at that line?

@echo off

pushd %~dp0\..

ionic cordova plugin remove com.mirasense.scanditsdk.plugin
del "platforms\android\app\src\main\res\drawable\*.xml"
del "platforms\android\app\src\main\res\layout\*.xml"
del "platforms\android\app\src\main\res\values\colors.xml"
ionic cordova plugin add lib\scandit

popd
Áxel Costas Pena
  • 5,886
  • 6
  • 28
  • 59
  • 3
    You've identified in your question, that `ionic` is actually `ionic.cmd`; you therefore need to use the `Call` command. i.e. `Call ionic cordova plugin remove com.mirasense.scanditsdk.plugin` and `Call ionic cordova plugin add lib\scandit`. – Compo Apr 20 '19 at 17:54
  • 1
    If you are using start, you are creating a separate process so it is highly unusual for that to be killing the original process. (1) are you showing your complete batch code? Perhaps there is an error somewhere in your script that causes a crash. (2) Can we have some more information about the program you are running? Maybe it does something faulty like close all command windows when it is done. – Samie Bencherif Apr 20 '19 at 17:55
  • 2
    It's not "something inside the ionic.cmd". It's the way you execute it (control is transferred to the executed `.cmd`. There is no return to the original script). Compo already showed the solution. – Stephan Apr 20 '19 at 18:12
  • 2
    I recommend reading my answer on [How to call a batch file that is one level up from the current directory?](https://stackoverflow.com/a/24725044/3074564) It explains four methods start or call a batch file from within a batch file. Please note that `pushd %~dp0\..` is not good. Better because of being100% correct and nearly always working is `pushd "%~dp0..\"`. The path referenced with `%~dp0` always ends with a backslash. So do not concatenate this path with an additional backslash with another file/folder string resulting in ``\\`` in folder path being automatically corrected by Windows. – Mofi Apr 20 '19 at 18:36
  • 1
    The path referenced with `%~dp0` could contain also one or more spaces and most critical also one or more `&` which requires enclosing the path in double quotes to pass such a folder path also correct to command `pushd`. The backslash at end would not be really necessary, but I prefer letting __directory/folder__ paths end with a backslash wherever this is possible or even recommended. – Mofi Apr 20 '19 at 18:43

1 Answers1

1

As requested, here's my comment as an answer.

You've identified that ionic is actually ionic.cmd; you therefore need to use the Call command, which allows return to the initiating script upon completion.

@Echo Off
Pushd "%~dp0..\"
Call ionic.cmd cordova plugin remove com.mirasense.scanditsdk.plugin
Del /Q "platforms\android\app\src\main\res\drawable\*.xml"
Del /Q "platforms\android\app\src\main\res\layout\*.xml"
Del "platforms\android\app\src\main\res\values\colors.xml"
Call ionic.cmd cordova plugin add lib\scandit
PopD
Compo
  • 36,585
  • 5
  • 27
  • 39