Page 1 of 1

Execute Native Commands

Posted: Mon Oct 27, 2014 4:22 pm
by standman
I have a simple test project to delete a file using the windows cmd.exe command. I'm just trying to test out functionality and I can't get it to work. XML is below. Anyone using cmd.exe?
Code: Select all
<project name="test" mainModule="Main" version="2.0" logLevel="debug">

	<module name="Main">

		<createWorkspace label="Create Workspace" version="1.0" />


		<exec executable="C:\Windows\System32\cmd.exe" version="1.0">
			<arg value="del C:\temp\test.rtf" />
		</exec>


		<deleteWorkspace label="Delete Workspace" version="1.0" />

	</module>

</project>

Re: Execute Native Commands

Posted: Mon Oct 27, 2014 5:14 pm
by Support_Rick
Try this:
Code: Select all
<project name="Test CMD" mainModule="Main" version="2.0" logLevel="debug">

	<module name="Main">

		<createWorkspace label="Create Workspace" version="1.0" />

		<exec executable="C:\Windows\System32\Cmd.exe" version="1.0">
			<arg value="/k" />
			<arg value="Del C:\Temp\Test.rtf" />
		</exec>

		<deleteWorkspace label="Delete Workspace" version="1.0" />

	</module>

</project>

Re: Execute Native Commands

Posted: Tue Oct 28, 2014 10:31 am
by standman
Rick, That worked. I've been going back and forth with support on this. Can you explain the use of the /k argument in the project? and will I need to call that prior to every argument or just before my list of arguments? Thanks in advance..

Re: Execute Native Commands

Posted: Tue Oct 28, 2014 10:48 am
by Support_Rick
The /k argument is from the definition of the CMD.EXE

/k : Carries out the command specified by the string but remains active
/c : Carries out the command specified by the string and then terminates

If you are going to use the CMD.EXE, please review the Help Text on that command and it will further explain. Otherwise, you should be able to address the ERASE or DEL commands directly without having to call the CMD.EXE.

Another option is to create a BAT file that contains the commands you want to execute and then just call the BAT file from the EXEC Task.

Re: Execute Native Commands

Posted: Tue Oct 28, 2014 10:58 am
by standman
All good options, Thanks for your insight.