Automate Command Prompt using blue prism

honey5

New Member
Hi,
I am endeavoring to make a BOT in RPA that will read excel records and afterward attempt to execute some standard commands from a command prompt utilizing the information in excel files. I am utilizing Blue Prism for this reason. While I am able to read excel files and store the data in the collection, I am not able to automate command prompt in Blue Prism. I tried to use a coding stage in c# to create a cmd process ( code is given below), but it does not recognize the 'Process' class.

System.Diagnostics.Process process = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo = new
System.Diagnostics.ProcessStartInfo();
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
startInfo.FileName = "cmd.exe";
startInfo.Arguments = "<command script>";
process.StartInfo = startInfo;
process.Start();


Please Guide Me on this

Thank You
Honey Asin
 

anisjolly

Administrator
Hi @honey5

You should have a Utility - Environment object which contains a Stat Process action which you can use to start the Command Prompt by simply adding "cmd" as an input. You can also pass through arguments using additional inputs.

This object is packaged as part of the standard Blue Prism install. If you cannot see it as part of your object library - have a look in your Blue Prism VBO folder under Program Files.
 

tgundhus

Member
I think "anisjolly" gave you the answer you were looking for, however.. Your c# code is correct, not sure why you got error on System.Diagnostics.Process, just remember to set C# as coding-language in the initialise dialog and refresh. You can also set System.Dianostics as namespace, but it should not be necessary when you define it like that. But, in order to do it this way, you will need to fix your argument (define it properly, just passing the script won't work).

If you wish to use Start Process and keep your windowStyle as hidden, I think you will need to use the start command with /B parameter.
 

Shiv

New Member
Manually save a blank notepad with .bat extension. Using write to txt file, write the commands into the .bat file. Execute this batch file from blue prism to run your commands.
 

tgundhus

Member
Manually save a blank notepad with .bat extension. Using write to txt file, write the commands into the .bat file. Execute this batch file from blue prism to run your commands.

To be honest, this is no good practise at all. If I ever review a setup like this, I should simply deny it. Please don't. Rather merge it into one code block or a cmd process executrix multiple commands.
 

Sukesh Kumaru

Active Member
Hi @honey5

You should have a Utility - Environment object which contains a Stat Process action which you can use to start the Command Prompt by simply adding "cmd" as an input. You can also pass through arguments using additional inputs.

This object is packaged as part of the standard Blue Prism install. If you cannot see it as part of your object library - have a look in your Blue Prism VBO folder under Program Files.
I used the VBO Utility - Environment and successfully launched CMD.exe process and next step is to send keystrokes to this application, how to do this one.
 
I used the VBO Utility - Environment and successfully launched CMD.exe process and next step is to send keystrokes to this application, how to do this one.
Hi Sukesh,

Did you get a solution for this.I am able to run the code from object.But it fails when i try to run it from the process.
 

VJR

Well-Known Member
Hi vivekbodduluri,

Can you respond your inputs to the below-
- What is the command you are using on the cmd prompt?
- What is the output your are getting?
- What is the text that you want to read from the above output?
 

sivagelli

Well-Known Member
You cannot read output of the command you entered on command prompt in to any data stage. One of the approaches you can take is to use Ctrl A + Enter keys to copy all the data on Command Prompt on to clipboard. Then paste the clipboard content on to a Data Stage -> use Calc Stage to manipulate the Data stage to read the required value.

There can be better ways, i am not aware.
 

VJR

Well-Known Member
i have to transpose data into note pad in local folder by command
Hi vivekbodduluri,

Did you mean transfer instead of transpose? And for which data you want this to be done? Is it some command you are inserting on the command prompt? If so which one?
 
Hi @honey5

You should have a Utility - Environment object which contains a Stat Process action which you can use to start the Command Prompt by simply adding "cmd" as an input. You can also pass through arguments using additional inputs.

This object is packaged as part of the standard Blue Prism install. If you cannot see it as part of your object library - have a look in your Blue Prism VBO folder under Program Files.
Hi @anisjolly
I used your method to run a python code. I don't need output into BluePrism. I passed arguments like this.

"python3" & """" &[script_file_path]&""""
this evaluated right. I am wondering Why it is not printed on the cmd screen.
Any Help will be greatly appreciated. All the other forms on this topic talk about using the code stage. I want to do it without using the code stage and application modeler. Is it Possible?
Any help is greatly appreciated.
Thanks in Advance
 
Top