web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Power automate desktop...
Power Automate
Unanswered

Power automate desktop unable to execute Vb and java script

(1) ShareShare
ReportReport
Posted on by

Iam unable to Execute VB and Java script using power automate Automate desktop after a windows update. The same code and script was running fine on the same VM before the windows update. What could be the issue. Any solution or leads would be highly appreciated. The script give blank output. Same script run fine when executed manually. 

I have the same question (0)
  • VishnuReddy1997 Profile Picture
    2,656 Super User 2025 Season 2 on at

    Hi @AjinkyaRPA2023 ,

     

    Just try restart the system and try.

     

    Regards,

    Vishnu Reddy

  • eetuRobo Profile Picture
    4,204 Super User 2025 Season 2 on at

    If the VBScriptOutput returns blank the it most likely encountered error. 

    Toggle on ScriptError -variable in your "Run VBScript" -action under "Variables produced"

    eetuRobo_0-1721113243458.png


    Then it might return something like this:

    C:\Users\XXXXX\AppData\Local\Temp\Robin\lxvgo4lvb4p.tmp(281) SAP Frontend Server: The control could not be found by id.

     

    That would mean that the vbscript ran into error in the scripts line 28

  • AL-16100634-0 Profile Picture
    on at

    Hi I Have tried it earlier also but no error in script error variable. The same script executes fine when executed manually by double click on the script and give the indented output.

  • AL-16100634-0 Profile Picture
    on at

    Hi Vishnu, I Have tried it to restart the machine and uninstalled and installed PAD and Services related to Power automate. Also checked if Cscript.exe and wscript.exe is present in windows/system32 folder. The same script executes fine when executed manually by double click on the script and give the indented output.

  • eetuRobo Profile Picture
    4,204 Super User 2025 Season 2 on at

    Can you show how your vbscript looks like and also screenshot of the flow.

    For troubleshooting add Wscript.Echos in multiple places in the script to see if it runs it at all. So maybe add one to be first line of code then in the middle and at the end 

    WScript.Echo "test1"
    //first half of your code
    WScript.Echo "test2"
    //rest of your code
    WScript.Echo "test3"

    Then maybe that will give us an idea where it fails or if the script runs at all.

     

     

  • AL-16100634-0 Profile Picture
    on at

    Option Explicit

    Dim excelApp, excelWorkbook, excelSheet, firstRow, secondRow, entireColumn, fourthRow, fifthRow, excelWorksheetFunction , rowIsEmpty4 , rowIsEmpty5

    ' Create an instance of Excel application
    Set excelApp = CreateObject("Excel.Application")

    ' Make Excel visible (for testing purposes)
    excelApp.Visible = False ' Set to False to run in the background

    ' Open the Excel workbook
    Dim fileName
    fileName = "%Path%" ' Update the path to your Excel file

    Set excelWorkbook = excelApp.Workbooks.Open(fileName)

    ' Specify the sheet you want to check
    Set excelSheet = excelWorkbook.Sheets("Sheet1") ' Update with the index or name of your specific sheet

    ' Create an instance of Excel's WorksheetFunction object
    Set excelWorksheetFunction = excelApp.WorksheetFunction

    ' Check if cell B1 is blank
    If excelSheet.Range("B1").Value = "" Then
        WScript.Echo "Invalid file"
        ' Close Excel
        excelWorkbook.Close False ' Close without saving changes
        ' Quit Excel application
        excelApp.Quit
        ' Clean up objects
        Set excelSheet = Nothing
        Set excelWorkbook = Nothing
        Set excelApp = Nothing
        ' End script execution
        WScript.Quit
    End If

    ' Check if cell B2 is blank
    If excelSheet.Range("B2").Value = "" Then
        WScript.Echo "Invalid file"
        ' Close Excel
        excelWorkbook.Close False ' Close without saving changes
        ' Quit Excel application
        excelApp.Quit
        ' Clean up objects
        Set excelSheet = Nothing
        Set excelWorkbook = Nothing
        Set excelApp = Nothing
        ' End script execution
        WScript.Quit
    End If

    ' Check if entire column A is blank
    Set entireColumn = excelSheet.Columns("A:A")
    If excelWorksheetFunction.CountA(entireColumn) = 0 Then
        WScript.Echo "Invalid file"
        ' Close Excel
        excelWorkbook.Close False ' Close without saving changes
        ' Quit Excel application
        excelApp.Quit
        ' Clean up objects
        Set excelSheet = Nothing
        Set excelWorkbook = Nothing
        Set excelApp = Nothing
        ' End script execution
        WScript.Quit
    End If

    ' Check if the 4th row is blank
    Set fourthRow = excelSheet.Rows(4)
    ' Check if the 5th row is blank
    Set fifthRow = excelSheet.Rows(5)

    ' If either the 4th row or the 5th row is blank, output "Invalid file"; otherwise, output "Valid file"
    ' Check if the fourth row is empty
    Dim cell
    rowIsEmpty4 = True
    rowIsEmpty5 = True
    For Each cell In fourthRow.Cells
        If Not IsEmpty(cell.Value) Then
            rowIsEmpty4 = False
            Exit For
        End If
    Next

    ' Check if the fifth row is empty
    If rowIsEmpty5 Then
        For Each cell In fifthRow.Cells
            If Not IsEmpty(cell.Value) Then
                rowIsEmpty5 = False
                Exit For
            End If
        Next
    End If

    ' If either the fourth or fifth row is empty, output "Invalid file"; otherwise, output "Valid file"
    If rowIsEmpty4 or  rowIsEmpty5 Then
        WScript.Echo "Invalid file"
    Else
        WScript.Echo "not"
    End If

    ' Close Excel
    excelWorkbook.Close False ' Close without saving changes

    ' Quit Excel application
    excelApp.Quit

    ' Clean up objects
    Set excelSheet = Nothing
    Set excelWorkbook = Nothing
    Set excelApp = Nothing

     

    This is the script which i execute using run script action in PAD which validates file format and then give Output  basis on which further code is executed. I have also tried to execute very basic hello msg script using PAD but even that give blank output and aslo no error.

  • AL-16100634-0 Profile Picture
    on at

    Screenshot 2024-07-16 150416.jpg

     

    Even the same code and script still work on my local machine using PAD but on the client VM where windows was updated.

  • eetuRobo Profile Picture
    4,204 Super User 2025 Season 2 on at

    Try this to see if it returns anything:

    Option Explicit
    
    Dim excelApp, excelWorkbook, excelSheet, firstRow, secondRow, entireColumn, fourthRow, fifthRow, excelWorksheetFunction , rowIsEmpty4 , rowIsEmpty5
    
     WScript.Echo "Script starts" 'TEST ECHO 1/3
     
    ' Create an instance of Excel application
    Set excelApp = CreateObject("Excel.Application")
    
    ' Make Excel visible (for testing purposes)
    excelApp.Visible = False ' Set to False to run in the background
    
    ' Open the Excel workbook
    Dim fileName
    fileName = "%Path%" ' Update the path to your Excel file
    
    Set excelWorkbook = excelApp.Workbooks.Open(fileName)
    
    ' Specify the sheet you want to check
    Set excelSheet = excelWorkbook.Sheets("Sheet1") ' Update with the index or name of your specific sheet
    
    ' Create an instance of Excel's WorksheetFunction object
    Set excelWorksheetFunction = excelApp.WorksheetFunction
    
    ' Check if cell B1 is blank
    If excelSheet.Range("B1").Value = "" Then
     WScript.Echo "Invalid file"
     ' Close Excel
     excelWorkbook.Close False ' Close without saving changes
     ' Quit Excel application
     excelApp.Quit
     ' Clean up objects
     Set excelSheet = Nothing
     Set excelWorkbook = Nothing
     Set excelApp = Nothing
     ' End script execution
     WScript.Quit
    End If
    
    WScript.Echo "Script middle" 'TEST ECHO 2/3
    
    ' Check if cell B2 is blank
    If excelSheet.Range("B2").Value = "" Then
     WScript.Echo "Invalid file"
     ' Close Excel
     excelWorkbook.Close False ' Close without saving changes
     ' Quit Excel application
     excelApp.Quit
     ' Clean up objects
     Set excelSheet = Nothing
     Set excelWorkbook = Nothing
     Set excelApp = Nothing
     ' End script execution
     WScript.Quit
    End If
    
    ' Check if entire column A is blank
    Set entireColumn = excelSheet.Columns("A:A")
    If excelWorksheetFunction.CountA(entireColumn) = 0 Then
     WScript.Echo "Invalid file"
     ' Close Excel
     excelWorkbook.Close False ' Close without saving changes
     ' Quit Excel application
     excelApp.Quit
     ' Clean up objects
     Set excelSheet = Nothing
     Set excelWorkbook = Nothing
     Set excelApp = Nothing
     ' End script execution
     WScript.Quit
    End If
    
    ' Check if the 4th row is blank
    Set fourthRow = excelSheet.Rows(4)
    ' Check if the 5th row is blank
    Set fifthRow = excelSheet.Rows(5)
    
    ' If either the 4th row or the 5th row is blank, output "Invalid file"; otherwise, output "Valid file"
    ' Check if the fourth row is empty
    Dim cell
    rowIsEmpty4 = True
    rowIsEmpty5 = True
    For Each cell In fourthRow.Cells
     If Not IsEmpty(cell.Value) Then
     rowIsEmpty4 = False
     Exit For
     End If
    Next
    
    ' Check if the fifth row is empty
    If rowIsEmpty5 Then
     For Each cell In fifthRow.Cells
     If Not IsEmpty(cell.Value) Then
     rowIsEmpty5 = False
     Exit For
     End If
     Next
    End If
    
    ' If either the fourth or fifth row is empty, output "Invalid file"; otherwise, output "Valid file"
    If rowIsEmpty4 or rowIsEmpty5 Then
     WScript.Echo "Invalid file"
    Else
     WScript.Echo "not"
    End If
    
    
    ' Close Excel
    excelWorkbook.Close False ' Close without saving changes
    
    ' Quit Excel application
    excelApp.Quit
    
    ' Clean up objects
    Set excelSheet = Nothing
    Set excelWorkbook = Nothing
    Set excelApp = Nothing
    WScript.Echo "Script ends" 'TEST ECHO 3/3

     
    I just added 3 wscript echos to see if it returns anything when you run it.
    For me it returns:

    eetuRobo_1-1721124365082.png

     


    I just had a dummy file with random words in cells. 

     

    Check that you can actually open the file you are running the vbscript on. For me it returned nothing when I tried to use it on a file that I was not able to open even manually. 

    Also make sure that you are looking at the correct variable for output. In your screenshot it will produce %VBScriptOutput2% from your vbscript action. So just make sure you are not looking only at the default %VBScriptOutput% -action.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard