Hi i want to execute the cd C:\iwatch\trunk\CPCE Client\EfileServiceClient command using variables pls help me out with the below variables.
I am saving this batch file in C:\iwatch\trunk folder so launchdir variable is have the folder name.
call "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat"
Echo OFF
set "var1=cd"
set "var2=Client\EfileServiceClient"
Echo Launchdir: "%~dp0"
Echo Currentdir: "%CD%"
set "var3=%cd% Launchdir%var2%
Echo %var3%
svcutil http://localhost:19012/EfileService/EfileService.svc
After executing the above batch file the proxy file is generating in C:\iwatch\trunk folder but i want to generate these files in C:\iwatch\trunk\CPCE Client\EfileServiceClient folder...
Example script to help you out.
#echo off
echo.CD=%CD%
mkdir "New Folder"
set var2="New Folder"
cd %~dp0%var2%
echo.CD=%CD%
pause
In your case set var2 to CPCE Client\EfileServiceClient then cd %~dp0%var2%. Hope this help!
Related
I have several Visual Studio 2015 solution files that I would like to build using a command line. I would like the output stored in a single file
Here is the contents of a batch file that builds the solutions.
echo off
call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat"
set _SCRIPT_DRIVE=%~d0
echo DRIVE %_SCRIPT_DRIVE%
set baseDir=%_SCRIPT_DRIVE%\Source\Service\4.0\Branches\ARES
echo baseDir = %baseDir%
set buildLog=%baseDir%\Build.log
rem these are the directory names / solution name of the projects I want to build
rem you can build 'n' solutions and use your own instead of me giving you the solution and code
set thirdParty=Cert,ManagedHooks,NLog,Newtonsoft.Json,RabbitMQ,MDTE
echo.
echo building %thirdParty%
echo.
for %%p in (%thirdParty%) do (
echo.
echo building %%p
cd %%p
set thirdPartySolutionFile=%%p%.sln
echo solution file : %thirdPartySolutionFile%
MSBuild %thirdPartySolutionFile% /t:Rebuild /m /p:Configuration=Debug > %buildLog%
cd ..
)
I only get the last project build information stored in the log file
>> is the answer
https://www.tutorialspoint.com/batch_script/batch_script_appending_files.htm
> overwrites the %buildLog% file.
>> will append the input to this file
so the line where you call the build tool and send the output to the file shoul d be changed to have the >> in it instead of >
MSBuild %thirdPartySolutionFile% /t:Rebuild /m /p:Configuration=Debug >> %buildLog%
I defined below command in jenkins windows batch command build step:
for /r %%f in (.\*.exe) do echo %%f
But the echo doesn't print the file name. Instead it just prints %f to the console.
I have tried with single % as below but it doesn't help. It prints f to the console.
for /r %f in (.\*.exe) do echo %f
How can I escape % character on jenkins build step? I am not sure whether it relates to jenkins only.
On Jenkins 2.60.2 on Windows 10, with two Firefox installer executables in my directory, running for /r %%f in (.\*.exe) do echo %%f in a Windows Batch command, I get the following output:
Building in workspace C:\Program Files (x86)\Jenkins\workspace\Test
[Test] $ cmd /c call C:\WINDOWS\TEMP\jenkins4832870824680456992.bat
C:\Program Files (x86)\Jenkins\workspace\Test>for /R %f in (.\*.exe) do echo %f
C:\Program Files (x86)\Jenkins\workspace\Test>echo C:\Program Files (x86)\Jenkins\workspace\Test\.\Firefox Installer.en-US.exe
C:\Program Files (x86)\Jenkins\workspace\Test\.\Firefox Installer.en-US.exe
C:\Program Files (x86)\Jenkins\workspace\Test>echo C:\Program Files (x86)\Jenkins\workspace\Test\.\Firefox Installer.exe
C:\Program Files (x86)\Jenkins\workspace\Test\.\Firefox Installer.exe
As you can see, it correctly treated the double %% as a single % when running the batch command, which makes sense, as it just calls cmd /c call on the temporary batch file that it creates, and that is the correct way of doing % syntax in a batch file.
I don't think it likely that this behavior would have changed much from different versions of Jenkins, but what version are you running? Can you post the full output of your batch command? Maybe there's something in there that can give us a clue.
I am trying to make a batch file for launching multiple pieces of software, they are not located in C drive however, and some of the folders have spaces in the name.
So far I have this..Chrome is the only one working.
#echo off
cd C:\Program Files (x86)\Google\Chrome\Application
start chrome.exe
cd /d D:\WEBDEV\SourceTree
start SourceTree.exe
cd /d D:\WEBDEV\Sublime%%Text%%3
start sublime_text.exe
Thanks
Update - SourceTree works, sublime isn't because of the spaces in the name.
Update - I believe the underscore isn't working.
Last Update - Got it to work, if anyone was wondering.
#echo off
cd C:\Program Files (x86)\Google\Chrome\Application
start chrome.exe
cd /d D:\WEBDEV\SourceTree
start SourceTree.exe
cd /d D:\WEBDEV\"Sublime Text 3"
start sublime.exe
Got it to work, if anyone was wondering.
#echo off
cd C:\Program Files (x86)\Google\Chrome\Application
start chrome.exe
cd /d D:\WEBDEV\SourceTree
start SourceTree.exe
cd /d D:\WEBDEV\"Sublime Text 3"
start sublime.exe
I am trying to write my first bat file. Sorry......
I need to input a source directory (dir) for another bat file to find test files and a destination directory (log) for the bat file to output its results.
The bat file that does the processing is called fits.bat.
-i Indicates that a file or directory to process will follow
-o Directs the FITS output to a file
I have this:
#echo off
cd c:\program files\fits\fits-0.8.0
SET /P dir=enter directory of source files
SET /P log=enter directory for log files
fits.bat -i %dir -o %log
pause
But I get no output at all.
If I type individual commands in command prompt window , it works and files in dir folder are correctly read and output is sent to the log folder
try this....
#echo off
cd c:\program files\fits\fits-0.8.0
set /p dir=enter directory of source files
set /p log=echo enter directory for log files
fits.bat -i %dir% -o %log%
pause
when you call variables you need a % in front and back
%VAR%
You need to surround your two variables in percent signs:
#echo off
cd c:\program files\fits\fits-0.8.0
SET /P dir=enter directory of source files:
SET /P log=enter directory for log files:
fits.bat -i %dir% -o %log%
pause
I want to copy all the *.jar files to another directory i wrote the below script
echo Enter path to ILM_HOME:
set /p ILM_HOME=
echo Deployment in progress
copy WEB-INF/lib/*.jar "%ILM_HOME%"/webapp/WEB-INF/lib
I use C:\Documents and Settings\asimon\Desktop\test as my input
It gives me syntax of the command is incorrect
I think the problem is Documents and Settings I even put "%ILM_HOME%" and I don't need c:\Docume~1\asimon\Desktop\test any other solution?
Update
This is working
#echo off
echo
echo Enter path to ILM_HOME:
set /p ILM_HOME=
IF EXIST "%ILM_HOME%\stopApplimation.bat" (
echo Deployment in progress
xcopy WEB-INF\lib\*.jar "%ILM_HOME%\webapp\WEB-INF\lib"
CALL "%ILM_HOME%\stopApplimation.bat"
CALL "%ILM_HOME%\startApplimation.bat"
) ELSE (
echo %ILM_HOME% path is incorrect.
)
also any linux solution is also helpfull with .sh for the below 2 statements
"%ILM_HOME%/stopApplimation.bat"
"%ILM_HOME%/startApplimation.bat"
for linux, how can i replace the above 2 statements?
$ILM_HOME/stopApplimation.sh
$ILM_HOME/startApplimation.sh
Did you try
xcopy WEB-INF\lib\*.jar "%ILM_HOME%\webapp\WEB-INF\lib"?
EDITED:
In your batch use CALL "%ILM_HOME%\stopApplimation.bat"