I want to run a bat file located in a specific location with some parameters.
If i cd to that location and then run the bat file with arguments, it works in command prompt. But how do i run it with absolute path in Jenkins?
I want to do something like this
call "C:\Program Files (x86)\SmartBear\soapUI-4.5.2\bin\testrunner.bat C:\Dev\COM\B2B\Vishal\SOAPUIGIT\B2bSoapUI.xml -s"Amend Order New Framework" -M"
however this gives an error saying
"The filename, directory name, or volume label syntax is incorrect."
Solved it.
The issue was with the double quotes.
Changing it to this worked
call "C:\Program Files (x86)\SmartBear\soapUI-4.5.2\bin\testrunner.bat" C:\Dev\COM\B2B\Vishal\SOAPUIGIT\B2bSoapUI.xml -s"Amend Order New Framework" -M
Related
Currently this is how I have written the code in the batch file:
C:\ cd C:\abc\xyz\build-scripts-master
call setEnv.cmd
cmd ant do-clean
cmd ant do-dist
This is not working. It just executes the setEnv and breaks out. It does not run the remaining commands
Manually this is how it works:
I first go to the folder C:\abc\xyz\build-scripts-master through the Command Prompt
Then I type in setEnv, which is a windows command script, and hit return.
Then I type in ant do-clean
And then ant do-dist
I want to automate this process and hence was trying to achieve this using batch file.
Try the following:
#CD /D "C:\abc\xyz\build-scripts-master"
#Call setEnv.cmd
#Call ant.bat do-clean
#Call ant.bat do-dist
The latter two lines assume that ant.bat is located somewhere in the current working directory or %PATH%
It is not imperative that the directory path is doublequoted in this case, just good practice.You could continue not to use the .bat extension with ant. I've included it just to make it clear that it is a batch file, and should be Called in the same way as the setEnv batch file.
it didn't run the bat files because you didn't specify the files' location in the code. As it stands right now, the script expects the .bats to exist in the working directory or it has been placed in the folder. The only way it will run the files arbitrarily is if you had placed your working location in the system variables or set the Path to the folders location. I don't know if the cmd and call are needed. I have never used them in my scripts.
I've searched in many posts that already deal with this kind of issue but I'm still not able to make it work in my case.
I'm trying to create a link file to Launch a bat file with cmd.exe (because the bat file launch a service in spy/console mode so the console has to be shown).
The bat file is created before the install process of the service.
The link file is created in Windows Start Menu while installing process, so it can embed the path where the exe file of the service is installed.
As the root path will be linked to cmd.exe, I need to pass the path of the exe of the service as an argument of the bat file, itself being an argument of the cmd.exe file...
I've tried the syntax given as a solution in this threat :
correct quoting for cmd.exe for multiple arguments
Spaces in Program Path + parameters with spaces :
cmd /k ""c:\batch files\demo.cmd" "Parameter 1 with space" "Parameter2 with space""
So in my case, I've writen:
cmd /k ""C:\Program Files (x86)\Company\Licenses Server\Debug Mode.bat" "C:\Program Files (x86)\Company\Licenses Server\""
Here is the content of the "Debug Mode.bat" file :
#ECHO off
net stop company.service
START %~f1ServiceFile.exe /console spymode
net start company.service
#ECHO On
But when I launch the link file, I get the message:
Windows cannot find C:\Program...
There must be a "quote" problem but I've tried a lot of different syntaxes and I cannot figure out what goes wrong here...
I have a .proj file (build.proj) that I'm calling using a .bat (build.bat) file via the command window.
build.bat:
%SystemRoot%\Microsoft.NET\Framework\v3.5\MSBuild.exe projects\build.proj /fl1 /flp1:LogFile=build.log;Verbosity=Normal
From an elevated command window I run
> build.bat
It runs through build.proj all the way up until it tries to call another .bat file.
Here is the line in build.proj where it calls this .bat file (test.bat):
<Exec Command="call $(BatchDir)\test.bat />
$(BatchDir) is defined at the top of build.proj and equals "..\batch"
In the console output I can see that it is trying to call the batch file:
call ..\batch\test.bat
"The system cannot find the path specified"
test.bat definitely exists relative the the projects folder. What am I doing wrong here?
Directory structure:
/MyProject
build.bat
/projects
build.proj
/batch
test.bat
Try using the full path to test.bat in the $(BatchDir) variable.
It looks like it's taking .. relative to either %SystemRoot%\Microsoft.NET\Framework\v3.5\MSBuild.exe or /MyProject/build.bat, neither of which have a ..\batch directory.
I need to invoke an exe file in C:\Program Files directory from a batch file.How can we mention the directory name "Program Files" in batch file.I am getting error like C:\Program not found.
I believe that % or ~ needs to be added in between but couldn't get it.Kindly assist.
Surround the script call with "", generally it's good practices to do so with filepath.
"C:\Program Files"
Although for this particular name you probably should use environment variable like this :
"%ProgramFiles%\batch.cmd"
or for 32 bits program on 64 bit windows :
"%ProgramFiles(x86)%\batch.cmd"
On my pc I need to do the following:
#echo off
start C:\"Program Files (x86)\VirtualDJ\virtualdj_pro.exe"
start C:\toolbetech\TBETECH\"Your Toolbar.exe"
exit
Now that bash is out for windows 10, if you want to access program files from bash, you can do it like so: cd /mnt/c/Program\ Files.
I use in my batch files - c:\progra~2\ instead of C:\Program Files (x86)\ and it works.
I had a similar issue as you, although I was trying to use start to open Chrome and using the file path. I used only start chrome.exe and it opened just fine. You may want to try to do the same with exe file. Using the file path may be unnecessary.
Here are some examples (using the file name you gave in a comment on another answer):
Instead of C:\Program^ Files\temp.exe you can try temp.exe.
Instead of start C:\Program^ Files\temp.exe you can try start
temp.exe
use this as somethink
"C:/Program Files (x86)/Nox/bin/nox_adb" install -r app.apk
where
"path_to_executable" commands_argument
Interestingly with variables ,this worked for me ...
SET "VESTADIR=\\%TARGET%\C$\"Program Files (x86)"\Cassidian\VESTA"
While createting the bat file, you can easly avoid the space. If you want to mentioned "program files "folder in batch file.
Do following steps:
1. Type c: then press enter
2. cd program files
3. cd "choose your own folder name"
then continue as you wish.
This way you can create batch file and you can mention program files folder.
I need to write a batch to rename a folder in Program Files.
I'm able to do it through the Explorer, so I guess I have all required rights.
But when I write something like this in a command line :
move "C:\Program Files\Ceebot4\train" train_old
I get the following error : Access denied.
Is it possible to do it ?
A batch file runs in MS-Dos mode and so is subject to different access rights to Windows Explorer. Try running your batch file or Dos prompt as an administrator should work
You are trying to move the contents to a directory named train_old right under the directory where you currently are when executing the command. If you want to rename the directory in current place you will have to use:
move "C:\Program Files\Ceebot4\train" "C:\Program Files\Ceebot4\train_old"
move moves things, so either do what Anders said (giving the full path in both places; but be careful the target name doesn't already exist), or use ren instead:
ren "C:\Program Files\Ceebot4\train" train_old