How to run a Windows PowerShell?

How to run a Windows PowerShell?

5

    Aug 03, 2007#1

    How can I run PowerShell scripts from UEStudio?
    Tried to create a command:
    powershell.exe -noexit &"%f"
    but get

    Error creating process...

    Tried other combinations, but got just about the same thing.

    Some future version of UEStudio will have special features to run PowerShell, but what do we do now?
    Thanks,

    6,682583
    Grand MasterGrand Master
    6,682583

      Aug 03, 2007#2

      After reading Running Windows PowerShell Scripts I think the mistake is that you use double quotes instead of single quotes.
      What if the path to the script file contains blank spaces? In that case you need to do the ampersand trick we showed you earlier; in addition, you need to enclose the script path in single quote marks, like so:

      powershell.exe -noexit &'c:\my scripts\test.ps1'
      And because you use -noexit and UltraEdit/UEStudio always waits until a called tool is terminated it is better to start powershell in a separate process. Try following:

      start "PowerShell Script" "powershell.exe with full path" -noexit &'%f'

      Don't forget to set option Program Type to Dos Program because Windows standard command start is a console application and not a Windows GUI application.

      Note: I don't have installed PowerShell nor know I anything about it. So I could not test what I have written here.
      Best regards from an UC/UE/UES for Windows user from Austria

      5

        Aug 07, 2007#3

        Mofi,

        Thanks for trying to help, but I still get error:

        Error creating process267: "C:\PROGRA~1\ULTRAE~1\UEDOS32.EXE" F C:\DOCUME~1\0061882\LOCALS~1\Temp\UE8E.tmp start "PowerShell Script"
        "powershell.exe with full path" -noexit &'D:\Will\PowerShell\Samples\Will\SearchIcons.ps1'

        Don't understand why IDM has not already solved this problem.
        Powershell will replace DOS and it can do so much more.
        Integration of Powershell and UEStudio/Ultaedit would be incredibly powerful.
        It can be used now on XP and Vista.
        Thanks,

        6,682583
        Grand MasterGrand Master
        6,682583

          Aug 08, 2007#4

          I have used Google and found following: An invalid working directory will generate an: 'Error creating process 267' alert window. I can confirm this.

          What do you have specified as working directory?

          The working directory must be specified always without double quotes, even when lower case %p is used and the path contains 1 or more spaces. If you have used double quotes for the working directory you get this error mesage.
          Best regards from an UC/UE/UES for Windows user from Austria

          5

            Aug 08, 2007#5

            Hello Troy,

            Appriciate your help. Got your example (simple directory listing) to work as you did.
            What I really wanted to do, however, was to use the 'current file' (%f) as a "batch or script" file (.ps1).
            I could always run a DOS batch file (CMD /K "%F") like that and I thought it was one of the greatest features of Ultraedit.


            Thanks,

            Hello William,

            Thank you for your message. I have never used PowerShell before, but I
            did install it and was able to get a simple directory listing to work as
            follows:

            COMMAND Tab
            Menu Item Name: PowerShell DIR
            Command Line:
            "C:\WINDOWS\system32\windowspowershell\v1.0\powershell.exe" dir
            Working Directory: %p

            OPTIONS Tab
            Program Type: DOS Program
            Save Active File selected

            OUTPUT Tab
            Command Output:
            Output to List Box selected
            Capture Output selected

            Replace selected text with: No Replace


            These settings correctly passed the output from the PowerShell EXE to
            the output window in UltraEdit-32 v13.10a+2. Does this help in your usage?

            I'm not sure what the "-noexit&'%f'" is intended to do in your command
            line. If you explain what you're trying to accomplish here I may be
            able to test this further.

            Thanks, Troy

              Aug 08, 2007#6

              Hello Mofi,

              Thanks for the help. Tried quotes on %p, but it did not seem to help
              Thanks,

              6,682583
              Grand MasterGrand Master
              6,682583

                Aug 09, 2007#7

                NO! Double quotes in the working directory field are NOT allowed. Your problem is that when you run the tool the working directory is not valid. That is the reason for the error message. Specify as working directory C:\ or an other directory were you have write permission or %p as Troy has done. You can use Filemon from SysInternals to look what's going on when you run your tool.

                5

                  Aug 09, 2007#8

                  Mofi,

                  Seems like the trouble may have been that I was giving it a program type of DOS rather than Windows. Will continue to experiment.
                  Yesterday I found I could use the %sel% as shown in the excerpt from the ini file:


                  Tool Cmd0=""C:\WINDOWS\system32\windowspowershell\v1.0\powershell.exe" %sel%"
                  Tool Dir0="%p"
                  Tool Menu0="New Tool 1"
                  Bitmap Path0=""
                  Show DOS Window0=0
                  Capture0=1
                  Capture Mode0=2
                  WinProg0=0
                  SaveAllFiles0=0
                  Save Active File0=0
                  Replace Type0=0

                  This will be very useful as well.

                  Again, Thank you very much for your help and interest. :)

                  -Will
                  Fullerton, California

                  Hello Troy,

                  Yes, that does work!!! Yes, that is what I wanted.
                  Thank you very much for your help.
                  ......................................................................................
                  Hello William,

                  Thank you for your response. What I was trying to demonstrate by using
                  the TYPE command is that the content of the active file IS passed
                  through PowerShell to the output window. The same should be true of any
                  other command involving PowerShell.

                  No one here is currently using PowerShell. If you're referring to a
                  PowerShell script (.psl) that you want to run please try the following:

                  COMMAND Tab
                  Menu Item Name: PowerShell
                  Command Line:
                  "C:\WINDOWS\system32\windowspowershell\v1.0\powershell.exe" -noexit "%f"
                  Working Directory: %p

                  OPTIONS Tab
                  Windows Program selected

                  OUTPUT Tab
                  Output to List Box selected
                  No Replace selected

                  Do NOT select Show DOS Box OR Capture Output

                  If you load a PowerShell script with the command line:

                  "C:\WINDOWS\system32\windowspowershell\v1.0\powershell.exe" -noexit "%f"

                  as referenced above, this should pass the contents of the active
                  file/script to PowerShell for execution and the "-noexit" should force
                  PowerShell to remain open after the script is executed. Is this what
                  you're looking for?

                  Thanks, Troy
                  Thanks,