# Add VBscript

**URL:** <https://forum.uipath.com/t/add-vbscript/351755>\
**Category:** Studio\
**Tags:** activities-panel, question, studio, system, activities\
**Created:** [October 8, 2021, 7:01pm UTC](https://forum.uipath.com/t/add-vbscript/351755 "2021-10-08T19:01:26Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Asitabha\_Deb\_asitabhad](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/asitabha_deb_asitabhad/32/176697_2.png) [@Asitabha\_Deb\_asitabhad](https://forum.uipath.com/u/Asitabha_Deb_asitabhad)\
**Post date:** [October 8, 2021, 7:01pm UTC](https://forum.uipath.com/t/add-vbscript/351755/1 "2021-10-08T19:01:26Z")

</div>

Hi All,

I would like to insert SAP script in UiPath.  
I have already add invoke VBscript activity, add the file name. Then nothing is happening.  
Please someone guide me, how to add argument and run my script.

---

<div class="post-metadata">

**Author:** ![postwick](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/postwick/32/227083_2.png) [@postwick](https://forum.uipath.com/u/postwick)\
**Post date:** [October 8, 2021, 7:54pm UTC](https://forum.uipath.com/t/add-vbscript/351755/2 "2021-10-08T19:54:27Z")

</div>

You don’t use UiPath to run scripts in other applications.

Tell us what you’re trying to do.

---

<div class="post-metadata">

**Author:** ![rahulsharma](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/rahulsharma/32/55062_2.png) [@rahulsharma](https://forum.uipath.com/u/rahulsharma)\
**Post date:** [October 8, 2021, 8:05pm UTC](https://forum.uipath.com/t/add-vbscript/351755/3 "2021-10-08T20:05:07Z")

</div>

You csn pass thr arguments easily to a vb script.

Regarding script for SAP, I assume you established a connection first with SAP?

> <https://stackoverflow.com/questions/2806713/can-i-pass-an-argument-to-a-vbscript-vbs-file-launched-with-cscript>

---

<div class="post-metadata">

**Author:** ![johnfelix](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/johnfelix/32/333254_2.png) [@johnfelix](https://forum.uipath.com/u/johnfelix)\
**Post date:** [October 9, 2021, 7:26am UTC](https://forum.uipath.com/t/add-vbscript/351755/4 "2021-10-09T07:26:59Z")

</div>

Hi @Asitabha_Deb_asitabhad

I have tried to run the sap script from excel application and when you copy paste the sap script it wont run out of the box.

you need to perform below steps to run the script from any external application such as excel or UiPath

1. Add reference SAP GUI Scripting API
2. Attach the existing SAP session
3. Run the SAP Script

**Reference SAP GUI Scripting API**

![SAP Gui reference](https://global.discourse-cdn.com/uipath/original/3X/a/2/a2849f96dcaa75da609f8434ed5dcbb1069ad596.png)

**Attach to SAP session**

[GuiApplication Object - SAP Help Portal](https://help.sap.com/viewer/b47d018c3b9b45e897faf66a6c0885a8/760.03/en-US/a020c8f8cfaf48ec9b579d5961889639.html)

[To connect and login SAP application automatically using VBScript - Visual Basic 4 / 5 / 6 (bytes.com)](https://bytes.com/topic/visual-basic/answers/945050-connect-login-sap-application-automatically-using-vbscript)

**Finally you can copy paste SAP Recording script in the invoke code and run**

I don’t suggest to use SAP scripting in Invoke code, because UiPath SAP activities are more than enough to accomplish many tasks

Let us know what you want accomplish with scripting, we can help you doing it using other activities

---

<div class="post-metadata">

**Author:** ![StefanSchnell](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/stefanschnell/32/173622_2.png) [@StefanSchnell](https://forum.uipath.com/u/StefanSchnell)\
**Post date:** [October 10, 2021, 5:24am UTC](https://forum.uipath.com/t/add-vbscript/351755/5 "2021-10-10T05:24:09Z")

</div>

@Asitabha_Deb_asitabhad

Hello Asitabha,

you can find examples how to pass arguments to a VBScript, in the context of SAP, in [SAP GUI Scripting Development Scenarios](https://forum.uipath.com/t/tip-sap-gui-scripting-development-scenarios-in-the-context-of-uipath) and in [How to check SAP Network Speed](https://forum.uipath.com/t/tip-how-to-check-sap-network-speed-during-the-runtime-of-a-workflow). You can find an example [how to detect connection and session number](https://forum.uipath.com/t/tip-how-to-detect-sap-connection-and-session-number-in-the-context-of-project), for a seamless SAP GUI Scripting integration. And also you have the possiblity to use a lot of standard window attributes.

![image](https://global.discourse-cdn.com/uipath/original/3X/8/3/8335a65990038391744b12902c49695e18e76283.png)

Best regards  
Stefan

---

<div class="post-metadata">

**Author:** ![Asitabha\_Deb\_asitabhad](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/asitabha_deb_asitabhad/32/176697_2.png) [@Asitabha\_Deb\_asitabhad](https://forum.uipath.com/u/Asitabha_Deb_asitabhad)\
**Post date:** [October 11, 2021, 12:43pm UTC](https://forum.uipath.com/t/add-vbscript/351755/6 "2021-10-11T12:43:00Z")

</div>

Hi @johnfelix,

Thanks for this feedback. Can you please help me what is the path of above check point.  
I have added all the parameter for run SAP script.  
Here is my script:

**If Not IsObject(application) Then**  
\*\* Set SapGuiAuto = GetObject(“SAPGUI”)\*\*  
\*\* Set application = SapGuiAuto.GetScriptingEngine\*\*  
**End If**  
**If Not IsObject(connection) Then**  
\*\* Set connection = application.Children(0)\*\*  
**End If**  
**If Not IsObject(session) Then**  
\*\* Set session = connection.Children(0)\*\*  
**End If**  
**If IsObject(WScript) Then**  
\*\* WScript.ConnectObject session, “on”\*\*  
\*\* WScript.ConnectObject application, “on”\*\*  
**End If**  
**session.findById(“wnd[0]”).maximize**  
**session.findById(“wnd[0]/usr/tabsTAXI\_TABSTRIP\_OVERVIEW/tabpT\01/ssubSUBSCREEN\_BODY:SAPMV45A:4400/subSUBSCREEN\_TC:SAPMV45A:4900/subSUBSCREEN\_BUTTONS:SAPMV45A:4050/btnBT\_PEIN”).press**  
**session.findById(“wnd[0]/tbar[1]/btn[29]”).press**  
**session.findById(“wnd[0]/tbar[1]/btn[7]”).press**  
**session.findById(“wnd[1]/usr/btnBUTTON\_1”).press**  
**session.findById(“wnd[1]/usr/btnBUTTON\_2”).press**  
**session.findById(“wnd[0]/tbar[0]/btn[3]”).press**

Please do let me know if I need to add any variable in the script. May be I missed that part.

BR/Deb

---

<div class="post-metadata">

**Author:** ![Asitabha\_Deb\_asitabhad](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/asitabha_deb_asitabhad/32/176697_2.png) [@Asitabha\_Deb\_asitabhad](https://forum.uipath.com/u/Asitabha_Deb_asitabhad)\
**Post date:** [October 11, 2021, 12:50pm UTC](https://forum.uipath.com/t/add-vbscript/351755/7 "2021-10-11T12:50:21Z")

</div>

Hi @postwick ,

I am trying to run SAP script through UiPath.  
I have recorded the script and trying to run in invoke VBScript activity but its not running and its showing “Green Tick” in Debug mode.

Here is my script  
**If Not IsObject(application) Then**  
\*\* Set SapGuiAuto = GetObject(“SAPGUI”)\*\*  
\*\* Set application = SapGuiAuto.GetScriptingEngine\*\*  
**End If**  
**If Not IsObject(connection) Then**  
\*\* Set connection = application.Children(0)\*\*  
**End If**  
**If Not IsObject(session) Then**  
\*\* Set session = connection.Children(0)\*\*  
**End If**  
**If IsObject(WScript) Then**  
\*\* WScript.ConnectObject session, “on”\*\*  
\*\* WScript.ConnectObject application, “on”\*\*  
**End If**  
**session.findById(“wnd[0]”).maximize**  
**session.findById(“wnd[0]/usr/tabsTAXI\_TABSTRIP\_OVERVIEW/tabpT\01/ssubSUBSCREEN\_BODY:SAPMV45A:4400/subSUBSCREEN\_TC:SAPMV45A:4900/subSUBSCREEN\_BUTTONS:SAPMV45A:4050/btnBT\_PEIN”).press**  
**session.findById(“wnd[0]/tbar[1]/btn[29]”).press**  
**session.findById(“wnd[0]/tbar[1]/btn[7]”).press**  
**session.findById(“wnd[1]/usr/btnBUTTON\_1”).press**  
**session.findById(“wnd[1]/usr/btnBUTTON\_2”).press**  
**session.findById(“wnd[0]/tbar[0]/btn[3]”).press**

Please do let me know if I miss anything.

---

<div class="post-metadata">

**Author:** ![LevKushnir](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/levkushnir/32/124465_2.png) [@LevKushnir](https://forum.uipath.com/u/LevKushnir)\
**Post date:** [October 20, 2021, 1:29pm UTC](https://forum.uipath.com/t/add-vbscript/351755/8 "2021-10-20T13:29:23Z")

</div>

Hi @Asitabha_Deb_asitabhad

I am super curios, why you would want to write a VB script and have all debugging stuff you discussing right now.

Why not to use UiPath Studio and UiPath activities to perform all your action with NO-CODE approach?

Thanks, Lev

---

<div class="post-metadata">

**Author:** ![Asitabha\_Deb\_asitabhad](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/asitabha_deb_asitabhad/32/176697_2.png) [@Asitabha\_Deb\_asitabhad](https://forum.uipath.com/u/Asitabha_Deb_asitabhad)\
**Post date:** [November 1, 2021, 2:57pm UTC](https://forum.uipath.com/t/add-vbscript/351755/9 "2021-11-01T14:57:04Z")

</div>

Hi @LevKushnir ,

I thing, activity with VBScript is much faster then normal sequence based approach.  
For certain repetitive task VBScript is more reliable then normal approach.

What do you think.

BR/Deb

---

<div class="post-metadata">

**Author:** ![LevKushnir](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/levkushnir/32/124465_2.png) [@LevKushnir](https://forum.uipath.com/u/LevKushnir)\
**Post date:** [November 2, 2021, 9:35am UTC](https://forum.uipath.com/t/add-vbscript/351755/10 "2021-11-02T09:35:31Z")

</div>

HI @Asitabha_Deb_asitabhad

Check this thread, where @StefanSchnell discussing the performance topic [Performance Consideration of an SAP GUI for Windows Automation](https://forum.uipath.com/t/performance-consideration-of-an-sap-gui-for-windows-automation/97506)

Best regards, Lev
