Run VB script in Powershell?


#1

Hi there, I am trying to run the following VB script using invoke powershell and I am having some issues. It runs fine in powershell however I can not get it to work in Uipath. I have isScript checked. Any suggestions ?

Const WD_SaveAsType = 2

Set objWord = CreateObject(“Word.Application”)
Set objDoc = objWord.Documents.Open(“C:\Users\HP 66012\Documents\attachments\rtftotext\purchorder 6167 13.09.16.rtf”)
objDoc.SaveAs “C:\Users\HP 66012\Documents\attachments\rtftotext\rtf.txt”, WD_SaveAsType

objWord.Quit

Thanks


#2

Could you share the workflow and the script you’re trying to launch?
Also, what error do you get?


#3

I see that you are trying to change the extension of the richt text format documet. have you tried to read it with UiPath and save it in a text file. Also if you are receiving warning policy you might want to change the policy to RemoteSigned for just the CurrentUser, you’d run the following command:

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

To to change the Execution policy, you must be running PowerShell As Adminstrator. If you are in regular mode and try to change the execution policy, you’ll get the following error:

Access to the registry key ‘HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell’ is denied. To change the execution policy for the default (LocalMachine) scope, start Windows PowerShell with the “Run as administrator” option.

Stackoverflow is the source.