I saved the below code as batch file but script able to install the tomcat service but not able to execute the line 4. Please let me know why it is not able to execute the line 4.
If i copied all the code and paste cmd window it is working fine and able to execute each command. but if double click on the batch file then not able execute the line 4 & 5. Please do the needful help. Thanks in advance
cd %CATALINA_HOME%
net stop SERVICE_NAME
sc delete SERVICE_NAME
service.bat install SERVICE_NAME
tomcat7.exe" //US//SERVICE_NAME --JvmMs=1024 --JvmMx=1024 --Jvm="C:\Program Files\Java\jre7\bin\server\jvm.dll" ++JvmOptions="-XX:MaxPermSize="512m" --Startup auto'
net start SERVICE_NAME
Use call command to start another batch script and return to calling batch as follows:
call service.bat install SERVICE_NAME
Recheck the tomcat7.exe line for proper use of " double quotes.
Use full paths to service.bat or tomcat7.exe if an error occurs similar to
'ddd' is not recognized as an internal or external command, operable
program or batch file.
Related
I have a notebook that I am trying to automatically execute using a batch file, but to do so I need it to launch in the Anaconda prompt. Based on the suggestions from this post, I was able to get the batch file to open it by calling the activate.bat, but it wouldn't run the second part.
#echo on
call %windir%\System32\cmd.exe "/K" C:\Users\mccom\AppData\Local\Continuum\anaconda3\Scripts\activate.bat C:\Users\mccom\AppData\Local\Continuum\anaconda3
papermill file.ipynb file_out.ipynb
Any tips?
Based on the Advice of Compo, calling papermill before calling anaconda worked.
#echo on
call C:\Users\mccom\AppData\Local\Continuum\anaconda3\Scripts\activate.bat
call papermill New_Send_Email_Personal.ipynb New_Send_Email_Personal_out.ipynb
pause
I have a problem in my jenkins job and I isolated into one command. So I created another separate job to try to fix it.
So in this job, called "teste" I only have one single command:
start cmd /k call "C:\Program Files\myDir\myBat.bat"
This opens a separate cmd window running my bat file, which should keep running "forever".
But the problem is when I do it, my jenkins job keeps stuck into a "exit 0" operation that I have no idea from where it came from.
Thats the console:
[EnvInject] - Loading node environment variables.
Building remotely on Machine01 in workspace C:\workspace\teste
[teste] $ cmd /c call C:\...dir\jenkins.bat
C:\workspace\teste>start cmd /k call "C:\Program Files\myDir\myBat.bat"
C:\workspace\teste>exit 0
Then it keep stuck at that point.
Example of myBat.bat content:
echo hi
pause
There's any way to make this call in another window without waiting for its finish?
I solve my problem changing the way I was calling my other .bat, calling it through powershell. But since I was from a bat file, I used the command to send a powershell command, calling my other bat file.
Also, I've added another line changing the jenkins BUILD_ID to a fake one, so it doesn't kill it.
So I changed from this line:
start cmd /k call "C:\Program Files\myDir\myBat.bat"
To this :
set BUILD_ID=dontKillMe
powershell -Command "Start-Process 'C:\Program Files\myDir\myBat.bat'"
I hope it helps someone someday.
I am running the following command in cmd for which I am able to get the log successfully.
cd C:\Users\sriram\AppData\Local\Temp\license1.1.4
C:\Users\sriram\AppData\Local\Temp\license1.1.4>lsmon.exe testprovilic.muc.company> C:\Users\sriram\AppData\Local\Temp\license1.1.4\usage.log
Above command will generate the logs in the usage log file. But I created a batch file as below for which it is giving me an error testprovilic.muc.company not found
#ECHO off
SET variable=C:\Users\s.d.vaidyanathan\AppData\Local\Temp\usage.log
START "C:\Users\s.d.vaidyanathan\AppData\Local\Temp\license1.1.4"lsmon.exe testprovilic.muc.company> "%variable%"
Could you please help me solve this issue.
Thanks and Regards,
Sriram
You need to add the "cd C:\Users\sriram\AppData\Local\Temp\license1.1.4" to the batch file. Or use the full path to the file like:
C:\Users\sriram\AppData\Local\Temp\license1.1.4\testprovilic.muc.company
So you would have ..
#ECHO off
cd C:\Users\sriram\AppData\Local\Temp\license1.1.4
SET variable=C:\Users\s.d.vaidyanathan\AppData\Local\Temp\usage.log
START "C:\Users\s.d.vaidyanathan\AppData\Local\Temp\license1.1.4"lsmon.exe testprovilic.muc.company> "%variable%"
or you could
#ECHO off
SET variable=C:\Users\s.d.vaidyanathan\AppData\Local\Temp\usage.log
START "C:\Users\s.d.vaidyanathan\AppData\Local\Temp\license1.1.4"lsmon.exe C:\Users\sriram\AppData\Local\Temp\license1.1.4\testprovilic.muc.company> "%variable%"
This doesn't work:
"C:\Users\s.d.vaidyanathan\AppData\Local\Temp\license1.1.4"lsmon.exe
The whole path needs to be in quotes and there needs to be a backslash after the last folder name.
Change it to this:
"C:\Users\s.d.vaidyanathan\AppData\Local\Temp\license1.1.4\lsmon.exe"
Open a command prompt window, type set and press key RETURN or ENTER to run this command. You get displayed all predefined environment variables with their current values. You can see TEMP, USERPROFILE and USERNAME.
Windows command line has a help. The command to get help is help, yes really. Try it out! You need help on command CD, enter in command prompt window help cd or alternatively cd /?. You need help on command SET and START, run help set or set /? and help start or start /?. All internal commands of cmd.exe and nearly all console applications support the parameter /? and output 1 or more help pages on running the command with this parameter.
You need a better overview of standard Windows commands? See Microsoft's command-line reference and SS64's command line reference.
I assume that sriram is your user account and s.d.vaidyanathan is the user account of someone else. By default a standard user has no permissions to access folders and files in a different user's profile than the own profile since Windows Vista. That means, you logged in as sriram can't access the files and folders of C:\Users\s.d.vaidyanathan because of missing permissions to do so. It would be necessary to use command Runas to run the batch file with account s.d.vaidyanathan.
#echo off
rem Execute lsmon.exe from license1.1.4 in my folder for temporary
rem files and folders and write the log file also into this folder.
"%TEMP%\license1.1.4\lsmon.exe" testprovilic.muc.company >"%TEMP%\license1.1.4\usage.log"
Note: Double quotes must be used around path AND file name. Just double quoting parts of a file name with path may or may not work depending on error correction and how the application is written. For details see answer on set environment variables with spaces.
See also the Microsoft article Using command redirection operators.
And regarding right usage of command START not really needed here see for example answer on How to call a batch file in the parent folder of current batch file?
I am trying to write below commands in batch file.
cd C:\Redis
redis-cli
select 6
file name is "xxx.bat"
It should connects to local redis instance and select database 6.
but it stops at second command "redis-cli". and does not even write second command "select 6"
on command prompt.
I mean i connects to server , but does not write next command.
I think i do not know something about executing commands in batch file.
I can run these commands outside of batch file without any problem.
Can somebody please spot the problem.
Regards
CMD does not pass the commands to the redis-cli.
You can test it with quit from the redis-cli, you will see a a CMD error for the select 6 command.
You should put all of your commands (without connecting with redis-cli) in a text file e.g test.txt and pass it all to to redis-cli. i.e:
type test.txt | redis-cli -x
p.s. there's no need to specify .exe or any other extension that is in you %pathext% variable, but it makes your scripts more readable.
Try
cmd /c "redis-cli select 6" >> output.txt
I need to specify exe with the command.
redis-cli.exe select 6
With my redis 2.4.6 on windows you can pass the command as an argument to the redis-cli executable. Here is my windows batch file:
SET REDIS_PATH=E:\Program Files\Redis
"%REDIS_PATH%\redis-cli" select 6
Of course you would change the redis path variable to wherever you have copied / installed Redis to.
Here is the output from running the windows batch file:
I am trying to execute a command CSRUN.exe with certain parameters from command prompt. I am able to do this using command prompt. Everytime instead of invoking this from the command prompt, i thought of writing a batch file, where in a single click will help me and also i forward this to someone who wants to execute.
Following is the one i am executing from the command prompt, which i want to have in a batch file
C:\Program Files\Windows Azure SDK\v1.1\bin>csrun.exe E:\Publish\ServiceConfiguration.csx E:\Publish\ServiceConfiguration.cscfg /launchbrowser
Can somebody suggest me how to create a batch file for invoking this command?
Just put those commands in a file
csrun.exe E:\Publish\ServiceConfiguration.csx E:\Publish\ServiceConfiguration.cscfg /launchbrowser
and name it something.bat
Just copy
csrun.exe E:\Publish\ServiceConfiguration.csx E:\Publish\ServiceConfiguration.cscfg /launchbrowser
inside an empty file and save it as a .bat..
Try using the start command and, if csrun.exe is not in your path you will need to specify an exact path for it:
start csrun.exe E:\Publish\ServiceConfiguration.csx E:\Publish\ServiceConfiguration.cscfg /launchbrowser
Save the above in a .bat file.
Also remember to put double quotes around paths with spaces in them.