I have a .bat file that has the following commands:
c:
cd %1
"c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" amd64 & for /f "delims==" %%F in ('dir /b *.pdb') do vsinstr /Coverage "%%~nF.dll"
I am executing the bat file from a cruise control project like this:
<exec>
<executable>cmd.exe</executable>
<buildArgs>"c:\Development\Batch Scripts\CodeCoverageSetup.bat" $(CodeCoverageSetupWorkingDirectory)</buildArgs>
</exec>
When the CC.Net project runs, the task is executed but it does nothing, and it runs indefinitely.
However, when I execute the batch script directly from cmd it executes perfectly.
Any ideas on how to get this to work?
PS: Any suggestions on how I can make CC.Net run the cmd window so that I can see what commands are being executed? Because the CC.Net shell does not give any useful debug info.
You are missing the /c for the cmd.exe to execute another process and exit at end.
Fixed exec block:
<exec>
<executable>cmd.exe</executable>
<buildArgs>/c "c:\Development\Batch Scripts\CodeCoverageSetup.bat" $(CodeCoverageSetupWorkingDirectory)</buildArgs>
</exec>
OR you can simply remove cmd.exe reference.
<exec>
<executable>c:\Development\Batch Scripts\CodeCoverageSetup.bat</executable>
<buildArgs>$(CodeCoverageSetupWorkingDirectory)</buildArgs>
</exec>
I can answer one part.
//PS: Any suggestions on how I can make CC.Net run the cmd window so that I can see what commands are being executed? Because the CC.Net shell does not give any useful debug info. //
Shut down the CC.NET (Service) (as in Control Panel-Services).
Run ccnet.exe from the command line. (It's values are pulled from ccnet.exe.config).
This will show everything that is happening in a command-window.
......
You can try the .bat file, but I usually end up recoding whatever happens in (what would be your "CodeCoverageSetup.bat") with a Task.
But I understand if you have a alot in CodeCoverageSetup.bat.
Try the command-prompt method and maybe it'll give you a hint about what is happening.
Related
On Windows 7 SP1, from CMD window, run command regsvr32 none.dll, regsvr32 will fail with exit code 3. This is the expected behavior of regsvr32, as stated in Raymond Chen's blog post.
Procmon verifies this as well.
However, when checking regsvr32's exit code with echo %ERRORLEVEL%, I got zero. WHY?
Thanks to Marks comment. I was just tripped by CMD's sneaky behavior.
To know the exit code of a GUI process like regsvr32, the CMD command line has to be:
start /wait regsvr32.exe none.dll
What is special about regsvr32 is: If we run regsvr /s xxx.dll , /s makes regsvr totally silent, looking very much like a CUI program. So users are more easily get trapped.
But if we execute regsvr32 none.dll inside a .bat/.cmd batch script, start /wait is not required. Such discrepancy (on command prompt vs inside batch script) often causes trouble for the unwary. Sigh.
I want to execute three bat files in my script, the problem is when i run these .bat files directly using execwait, command windows gets open, I want to hide these command windows but its not working. My code is of just 3 lines.
ExecDos::exec '"catalina_start.bat"'
ExecDos::exec '"mysql_start.bat"'
ExecDos::exec '"apache_start.bat"'
I also tried this nsExec command but still no solution:
nsExec::Exec "cmd /C catalina_start.bat"
nsExec::Exec "cmd /C mysql_start.bat"
nsExec::Exec "cmd /C apache_start.bat"
A little background on these .bat files, Actually these are files of xampp setup, xampp internally uses these files to start tomcat, mysql, and apache.
The problem I am facing is that only first bat file gets executed, i. e. tomcat gets started (I can see that in xampp console), but then script dosen't move ahead, sql and apache is not getting started.
Does the batch-file contain pause or something else that prevents it from completing?
You should start off just by using something like ExecWait '"cmd.exe" /k "$InstDir\catalina_start.bat"' (or /c) so you can see the text written to the console including any errors. Once it works correctly you can switch to one of the exec plugins that hides the console...
You can change command windows from cmd /C catalina_start.bat to start /Min cmd /c catalina_start.bat it will hide command windows
This seems like it should be ridiculously simple but I cannot find the answer online or in these forums.
I want to run a command from a batch file, leave the command window open and end at a particular file location.
I can't seem to get both to happen in the same window. This is for a script to run an automated task everytime and leave the window open to run a 2nd task that has a variable input.
start cmd /k c:\users\test\desktop\dmiwtool1.1\win64\dmiwtoolx64.exe & cd c:\users\test\desktop\dmiwtool1.1\win64\
If I run either by itself, they work (runs the exe, ends at /desktop prompt), but in this sequence only the first runs.
this works here:
#ECHO OFF
START /b "" "path\program.exe" "parameter"
CD %UserProfile%\Desktop
Do not use setlocal in your Batch or put endlocal in the line before the CD command.
This should work:
start cmd /k "c:\users\test\desktop\dmiwtool1.1\win64\dmiwtoolx64.exe & cd c:\users\test\desktop\dmiwtool1.1\win64\"
If you leave out the quote marks, the start command and the cd command are run separately.
Im using a command line prebuild task in the ccnet.config file to delete the contents of thw working directory before i do a clean build.
<prebuild>
<exec>
<executable>%SYSTEM32%\cmd.exe</executable>
<buildArgs>/c "if exist "C:\CruiseControl\Working" rd /s /q "C:\CruiseControl\Working""</buildArgs>
</exec>
</prebuild>
The problem is I get an error:
System.IO.IOException: Unable to execute file [C:\CruiseControl\Working\cmd.exe].
it seems to be looking for cmd.exe in the working folder.
So I tried adding the path to cmd.exe instead as follows:
<prebuild>
<exec>
<executable>%SYSTEM32%\cmd.exe</executable>
<buildArgs>/c "if exist "C:\CruiseControl\Working" rd /s /q "C:\CruiseControl\Working""</buildArgs>
</exec>
</prebuild>
Any help would be great?
I have found the answer to my original question:
I simply had to put the cleanCopy true inside the sourcecontrol block.
<sourcecontrol type="svn">
<trunkUrl>TRUNK-URL</trunkUrl>
<executable>SVN.EXE</executable>
<username>TEST</username>
<password>TEST</password>
<cleanCopy>true</cleanCopy>
</sourcecontrol>
The path where is located cmd.exe is in your %PATH% Environment variable. You don't need to explicitely set it (you can verify it by typing cmd in the execute prompt) :
<prebuild>
<exec>
<executable>cmd.exe</executable>
<buildArgs>/c "if exist "C:\CruiseControl\Working" rd /s /q "C:\CruiseControl\Working""</buildArgs>
</exec>
</prebuild>
As for the directory use problem. I think you wish to delete a subdirectory of C:\CruiseControl\Working instead of the whole Working. It could also be that svn or another process is working on it. What happens if you run
if exist "C:\CruiseControl\Working" rd /s /q "C:\CruiseControl\Working"
directly in cmd?
I have the same problem with cmd.exe in a block. I have cleanCopy set to true in a multi source control block with Source Gear Vault. Nothing here or anywhere else has solved this problem other than putting my single line command into a .cmd file, but I would rather not have to create a .cmd for every little line I need to run from the command prompt.
I know using External Tools options i can run a batch script or a cmd prompt. But here is what i need to do
I want to be able to call a dos prompt inside visual studio, which must be interactive. That way i won't be outside visual studio and can run all my dos commands in it. Is it possible? Or can i extend the command window and capture the commands which are typed and process them using my custom code?
Thanks
There's the Tools.Shell command which may work for you. You use the /c switch to specify that the output for the executable is displayed in the Command window. Then you call cmd.exe with /C switch which instructs it to close after finishing the command. For example if you type:
Tools.Shell /c cmd.exe /C dir C:
This will print the output to the Command window. Unfortunately, unlike the output, the input doesn't work. So if you type:
Tools.Shell /c cmd.exe /C pause
The prompt will not wait for your input (pressing a key).
If that's OK for you, you can even define an alias for most of this. For example you define alias sh for Tools.Shell /c cmd.exe /C:
alias sh Tools.Shell /c cmd.exe /C
Then you simply use it as follows:
sh dir c:
If you install NuGet, then it adds Package Manager Console to Visual Studio which is essentially a Powershell command prompt. There should be ways of doing most DOS stuff via Powershell and heaps more functionality as well.
Not exactly what you are asking for, but I think you could manage to achieve your goal with StudioShell:
http://studioshell.codeplex.com/
Have to admit that I did not use it so far but it looks very interesting.