Some CLI services need to run on the same server as the third-party application system. In accordance with common methods of operation, this time will usually build the business needs of the environment, such as the installation of certain software, configuration environment variables. Sometimes the version of Java or PHP may be different, sometimes the local server does not have the relevant environment. Doing so will pollute the environment of the third-party application system (which may vary in degree).
It is possible to avoid contamination by operating in the following manner.
Extract the necessary DLL files to a specific folder, unzip Java or PHP and place them under the relevant folder.
Define a batch document, add the above two folders to the environment variable (only valid under current command-line process at this time)
For example:
Title A System interface
Set path=%path%;D: \amsoainterface\extforwin;
@ D:\AmsOaInterface\php\php.exe D:\AmsOaInterface\Entrance\index.php home/index/index.html
When you test Java or PHP at the command line, you need to set environment variables or frequently enter a path, which is more cumbersome and defines the following batch processing:
Title "Java CMD"
Set Path=d:\java\jdk1.8.0_60\bin; C:\Windows\System32
Cmd
::p ause #Here is the comment
When the batch finishes executing, the current process is ended by default. If you pause execution with pause, you cannot enter additional command execution.
By adding cmd at this point, you can bring up the CLI in the current process and continue executing other commands. When setting an environment variable, you need to add the folder where the cmd is located (or add the current system all environment variable%path%), or the window will close automatically when the command is not found.
A quick way to perform command-line operations in Java or PHP