Announcement

Collapse
No announcement yet.

Running Powershell Script from inside Setup Factory

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • j.heatherington
    replied
    Thank you, it was indeed missing backslashes!
    Thanks again,
    John

    Leave a comment:


  • Ulrich
    replied
    Without seeing the actual code, it is impossible to say for sure what you are doing wrong, but just looking at the text you pasted, it appears as there are many missing backslashes.

    Ulrich

    Leave a comment:


  • j.heatherington
    replied
    Hi there,
    I've tried to run powershell from inside Setup Factory but I get a script error (with no error stored in Application.GetLastError()) when I try to run it.
    My setup factory code is
    success1 = File.Run("C:\Windows\System32\WindowsPowerShell\v1 .0\powershell.exe","C:\Docs\Latest\Work\2022\01-January\Test1.ps1","C:\Docs\Latest\Work\2022\01-January",SW_SHOWNORMAL,false);

    If I run (from a CMD command line) C:\Windows\System32\WindowsPowerShell\v1 .0\powershell.exe C:\Docs\Latest\Work\2022\01-January\Test1.ps1 it works perfectly (the Test1.ps just writes some output to a file using:
    Get-ChildItem "C:\Windows\System32" | Out-File "C:\Docs\Latest\Work\2022\Test.txt"
    )

    What am I doing wrong? The powershell command works fine when not run from Setup factory, but seemingly not from within.
    Thanks in advance,
    John






    Leave a comment:


  • Ulrich
    replied
    Sure, check the documentation and see how you can pass a script to Powershell.exe as the argument, then perform the action with File.Run().

    Ulrich

    Leave a comment:


  • Running Powershell Script from inside Setup Factory

    Hi All,
    Is it possible to run a powershell script from within Setup Factory?
    Thanks,
    John
Working...
X