Why does run command loads another console in window? - batch-file

I am running my Java application made by gradle-gretty-plugin and the file for it is like the following:
:execute
#rem Setup the command line
echo "REDCA AGENT RUNNING.."
set APP_NAME=redca-agent-1.0.0-SNAPSHOT.jar
set CONFIG_HOME=%APP_HOME%\config
set CLASSPATH=%APP_HOME%\lib\*
set CONFIG_LOC=--spring.config.location=file:%CONFIG_HOME%\application.properties
set APP=com.sds.redca.agent.Bootstrap
#rem Execute redca_agent
echo "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %APP% %CONFIG_LOC% %CMD_LINE_ARGS%
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% -classpath "%CLASSPATH%" %APP% %CONFIG_LOC% %CMD_LINE_ARGS%
When I run this in my local, it runs in same console where I run this command. And I uploaded to this application to the server where Windows Server 2008 R2 Enterprise Service Pack1 is installed.
The problem is that it loads another console that is not the one where I run command. So If the application gets error, I can't see the log. Because the new console window is closed right after it show error logs.
I can't understand why the same application run differently.

I found the workaround about this problem. I don't know the exact reason for that. But I changed Java and it worked.

Related

Batch File to start application restarts itself again and again

I'm trying to create a batch script to activate a conda environment and start an application within it (which has been previously installed).
But for whatever reason, the application doesn't start but the batch script itself restarts again and again.
I'm using the following script:
#ECHO OFF
ECHO Activate Environment ...
call activate ENV
ECHO Start application ...
ApplicationName
PAUSE
The output if I start the batch script by doubleclicking it is:
Activate Environment ...
Start application ...
Activate Environment ...
Start application ...
Activate Environment ...
Start application ...
I also tried with call ApplicationName and start ApplicationName but this doesn't work either. The application I would like to start is an own application which can be installed via pip (Python application, entrypoint specified in setup.py).
The normal use is to open a cmd or the Anaconda prompt, activate the environment manually and enter the command ApplicationName on the command line. After this the application triggers a browser window to open a login screen. When I use the application like that the command line window stays open during the execution of my application and prints debug messages.
I just don't understand why the commands are repeated again and again instead of that the application is started.
Do you know what causes the behaviour?
Thank you in advance for an answer!
Best Regards
Your batch file has the same name as your undisclosed ApplicationName.
Therefore the batch file will restart ApplicationName.bat instead of ApplicationName.exe

installing windows service from command line "The specified service has been marked for deletion"

I am trying to create a batch file to automate uninstalling, building and reinstalling a windows service.
After uninstalling when I try to reinstall I get the error: The specified service has been marked for deletion.
here is the batch script:
#ECHO off
set filePath=<myfilepath>
set serviceName=<myservicename>
sc query %serviceName% > nul
if %ERRORLEVEL% EQU 0 net stop %serviceName% & sc delete %serviceName%
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe C:\Users\Christopher\Desktop\TFS\MOC\LaneUpdateService\LaneUpdateService.sln /property:Configuration=Debug
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\installutil.exe %filePath%
sc start %serviceName%
I do not have task manager, services or event viewer open, there are no other users logged in. I have tried deleting the reg key for my service, with no luck. If I run my script again after it failing it will install correctly. Is there a way to manually make sure the service is fully deleted?
The problem was that after stopping my service there was still a process running. I altered my onstop method to make sure all processes were stopped correctly. now the batch file works correctly. As #Harry Johnston suggested I will be adding a while loop to the batch file.

Trying to uninstall a program with wmic and getting error 1603

I'm try to create a batch file that will, among other things like installing the newest version of our software, first UNINSTALL the old version. I have used "wmic product get name" to find the actual name of the program, and then I have scripted the following code to uninstall the program:
wmic product where "name like 'Borland CaliberRM 10.1'" call uninstall /nointeractive >> C:\users\pbrandvold\Desktop\log.txt
When it's finished, I get this message:
Executing (\\PHIL-BRANDVOLD\ROOT\CIMV2:Win32_Product.IdentifyingNumber="{ED8B0A1F-8E90-478A-82B6-7C885A628257}",Name="Borland CaliberRM 10.1",Version="10.1.0.84")->Uninstall()
Method execution successful.
Out Parameters:
instance of __PARAMETERS
{
ReturnValue = 1603;
};
I can't think of what is happening - why won't this uninstall? I've also tried using the msi, and running:
msiexec.exe /qn /x "Borland CaliberRM 10.1.msi"
Which doesn't work either.
I had this issue when trying to uninstall and reinstall Web Deploy using wmic via a batch file. It did not help running the batch file with elevated privileges.
The only way I could get it to run correctly was to open a Command Prompt window with elevated privileges and run the batch file through that.
The solution I ended up going with was to turn my batch file into an executable using a Bat to Exe converter. http://www.f2ko.de/en/b2e.php
The issue occurs due to the user's privileged of uninstalling the program.
Just open the command prompt as 'Run as administrator and run your command to uninstall the program.
Example :
open cmd with admin:
run below commands
wmic
product get name
product where name="YOUR_PROGRAM_NAME" call uninstall

Batch script not doing anything when execute from remote machine using ssh

i'm having a problem while executing batch script from linux machine.
Scenario:
I've a windows machine installed server2008, I need to automate some windows task that executes from linux machine. I've installed cygwin software on windows VM and create a batch script that is running fine from cygwin terminal. i.e cd ~/;./script.bat
Problem:
When I execute the same script from linux machine using ssh it seems works fine and print script executed successfully but when I checked that the task from windows it did nothing.
cat script.bat
#echo off
set sourcePasswd=%1
set destinationPasswd=%2
set destinationProjectName=%3
set user=%4
set xmlPath=C:\cygwin\home\%user%\Duplicate.xml
ECHO Start : Duplication project source for %destinationProjectName%
"C:\Program Files (x86)\Common Files\MySoftware\Duplicate.EXE" -f %xmlPath% -sp %sourcePasswd% -dp %destinationPasswd% -sup -md -dn %destinationProjectName%
ECHO Finish : Duplication project source for %destinationProjectName%
Looks like Leopard hasn't been back since he posted the question or the link to the answer, so I'll be the Point Pimpette tonight and fill in the blank.
The answer below is from the link:
http://cygwin.com/ml/cygwin/2010-07/msg00598.html
It was fixed after doing the following setup :
Open control panel=> Administrative Tools=>Computer
Management=>Services
lookup the sshd service, right
click=>properties=>log on, and check the checkbox for Allow service
to interact with desktop
restart the service.
thanks
Saravana

.bat Script Terminating Before AWS Auto Scaling Commands Executed

I am fairly new to Amazon Cloud Auto Scaling (and AWS all together).
I am currently trying to write a .bat script that will automatically create a launch configuration and then an auto scaler. The aim is for an image that was previously set up about a week ago by a coworker.
The problem I encounter is that when I run the script, no commands past the launch configuration command is executed.
The code is here:
echo Beginning Auto Scale Up Process
REM Create a launch config
as-create-launch-config --image-id ami-xxxxxxx --instance-type t1.micro --user-data "Created by Launch Config reportingServerScaleUp-lc" --launch-config reportingServerScaleUp-lc
echo Timer Complete
I am looking for suggestions to help me debug this issue. Or advice on how to solve it. After the "echo Timer Complete" I have a command to create an auto scaler. Though, not even the "echo Timer Complete" is executed. The console does return indicating that the launch configuration is created though :)
Also, when I enter each command sequentially into the command line, each executes perfectly. The launch configuration is created as is the auto scale group.
It turns out that the AWS commands call exit which exits the .bat script prematurely.
Prepending each AWS command with "call" did the trick.
I found suggestions in this question: Why does only the first line of this Windows batch file execute but all three lines execute in a command shell?

Resources