0

I am trying to import a PowerShell module using inno Setup and execute with the following code but when I run it doesn't run the script with the parameters I have mentioned someone please help me out what I am doing wrong.

    [Run]
Filename: "powershell.exe"; \
Parameters: "New-ChromeExtension -ExtensionID 'agckcglooaipjmbeipibmbffnogjfdfb' -Hive Machine -File ""{app}\New-ChromeExtension.ps1"""; \
WorkingDir: {app}; Flags: runhidden

Here are the commands to execute from direct PowerShell

Import-Module C:\Scripts\New-ChromeExtension.ps1
New-ChromeExtension -ExtensionID 'bmnlcjabgnpnenekpadlanbbkooimhnj' -Hive Machine

Thanks

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
Tuk Tuk
  • 57
  • 5
  • The answer provided to me here had an example of using PowerShell. https://stackoverflow.com/a/64970085/2287576 I don't know if it helps you. – Andrew Truckle Dec 03 '20 at 05:39
  • See [How to run a PowerShell Script after Inno Setup installer](https://stackoverflow.com/q/56419077/850848). – Martin Prikryl Dec 03 '20 at 06:48
  • @MartinPrikryl I have tried the link you have mentioned but its not working as expected, Am I using the proper parameters which I mentioned in the question.! – Tuk Tuk Dec 03 '20 at 08:10
  • So show us what did you try based on the link. The command-line syntax in your question is different than what my answer shows and it's simply wrong. – Martin Prikryl Dec 03 '20 at 08:12
  • @MartinPrikryl This is what I have tried also I dont know that i am using the proper format from that link `[Run] Filename: "powershell.exe"; Parameters: \"-ExecutionPolicy Bypass -Command New-ChromeExtension -ExtensionID 'agckcglooaipjmbeipibmbffnogjfdfb' -Hive Machine""{app}\New-ChromeExtension.ps1"""; \ WorkingDir: {app}; Flags: runhidden` – Tuk Tuk Dec 03 '20 at 08:20
  • I do not see any `Import-Module` there. The `\"` looks wrong too. – Martin Prikryl Dec 03 '20 at 08:22
  • The Truth is I have no idea how to use it so tired googling and found that answer based on that answer I tried but it did not worked so I thought its better to get some help from experts and learn from my mistakes, Here what I am trying to do I have to import a ps1 module from C Drive and execute that with the following command ( New-ChromeExtension -ExtensionID 'bmnlcjabgnpnenekpadlanbbkooimhnj' -Hive Machine ) when I do it manually the script works and with the current code I have its not working so please help me out. – Tuk Tuk Dec 03 '20 at 08:28
  • 1
    I do not understand your problem. You know what commands to use interactively in PowerShell. So why don't you use the same commands, when trying to automate it? `-ExecutionPolicy Bypass -Command Import-Module C:\Scripts\New-ChromeExtension.ps1 ; New-ChromeExtension -ExtensionID 'bmnlcjabgnpnenekpadlanbbkooimhnj' -Hive Machine` – Martin Prikryl Dec 03 '20 at 09:00
  • Usually a `.ps1` file isn't a module (usually modules are `.psm1`). So I don't know why you need `Import-Module` before running your script command; your PowerShell code seems to be incorrect (but hard to say since I can't see your script). – Bill_Stewart Dec 04 '20 at 17:31

0 Answers0