Pass the argument into Start Process


#1

Hello,
anyone could tell me, how do I properly pass arguments into Start Process activity?
I’m trying to start simple .vbs e.g.:

Dim title
x=msgbox(“B”,0, title)

And I want to pass title argument in UiPath in arguments box in activity. I’ve tried to pass string in quotation marks, with assigning “title=string”, nothing worked.
Where I am wrong? How to do it? I have to change something in the script?


#2

Can u share the workflow ?


#3

messagebox.xaml (6.5 KB)

Script vbs:
Dim title
x=msgbox(“B”,0, title)


#4

Could it be that the “start application” activity is looking exclusively for .exe files, not .vbs?


#5

No.
I have another Start Process with .vbs and it’s working. I want to do the same, but with passing arguments, but I don’t know how to.


#6

In which case might this help?


#7

Passing argument like this does not work.


#8

Hi, is there a solution to this issue where vbs file is not accepting arguments passed via Start process activity in UIpath? Or do I need to specify something in vbs file to use this argument? I am facing this issue, please help.
image

My vbs code is starting as below (varDirectory is the variable to which this argument should be passed):

msgbox varDirectory
Call Func_Filter_Excel(varDirectory)
Public Function Func_Filter_Excel(ByVal sPath)
Set objExcel = CreateObject(“Excel.Application”)


#9

Hi @vikkhanna55

Start Process starts an application, but .vbs file is a file, not an application. So, you need to open the .vbs file with an application (probably cscript.exe). Then, to use arguments place them next to the filename like you would if you were calling it a command prompt.

Also, the arguments field where the filename goes should be surrounded by embedded quotes (again, just like you would in command prompt)

image

Hopefully that helps.

Regards.


#10

Oh also, you might need to call it with Powershell, if it requires to run as admin.

example .ps1 file
invoke-expression “cmd /C cscript ‘filepath.vbs’ vikas”

image

You can also utilize the parameters property to send “vikas” as an argument to the script.

Regards.


#11

Hi Clayton,

Thanks for your quick inputs, but am still not sure how my vbs code will use these arguments. My arguments will again be string variables created in uipath, please guide me how to implement it.

Thanks!


#12

I did a quick search and found this that might help:

It says WScript.Arguments(0) or WScript.Arguments.Item(0) can be used to access the arguments. You would need to use this in your vbscript.

You might want to test this with some script editor where you can pass arguments, or even call it from command line, like
c:\windows\system32\cscript.exe "C:\folderpath\Program_Filter_Excel.vbs" "vikas"

Once it is set up to use arguments, then you can set up your Start Process as suggested.
image

That example is not using variables though.

I hope that helps further.

Regards.


#13

Thank you Clayton! This will surely help.
Much appreciate for your guidance.

I will post again after implementing the solution.


#14

Hi,
You may follow below steps:

  1. Use ‘Invoke Code Activity’ and use the code in below format:
    System.Diagnostics.Process.start(“{VBS File Path}{VBS File Name}.vbs”,Argument1 &" “& Argument2)
  2. Pass value as argument to vbscript as:
  3. In your VBScript utilize passed on values in variables like:
    Set args = WScript.Arguments
    VarArg1 = args.Item(0)
    VarArg2 = args.Item(1)
  4. Above method will allow variable VarArg1 to get passed on Argument1Value and VarArg2 to get passed on Argument2Value
  5. Now you may utilize VarArg1 and VarArg2 as per your need in the vbscript code.

Hope this helps. Feel free to ask for help if you get stuck or need further explaination


#15

I am getting below error while using start process activity.

"There is no script engine for file extension “.xlsx”.
The argument I am passing is having full path to an excel like
“C:\Bot\FilteredReport.xlsx”


#16

Found the problem, missed to provide space between .vbs file and the argument (which was having file path as value)

Thanks Clayton and Ankit :slight_smile:


#17

Marking this as Resolved. Thanks!