locked
Why is appx built with ps1 file rather than bat file?

Answers

  • @Stefan - powershell script directly was a better and more secure option than a traditional batch file for these purposes.  The batch file additionally just called powershell anyway, so removing a layer and ensuring we were using the same APIs/methods that we'd ask customers to use was preferred.

    Tim Heuer | Program Manager, XAML | http://timheuer.com/blog | @timheuer

    (if my post has answered your question, please consider using the 'mark as answer' feature in the forums to help others)

    Tuesday, June 5, 2012 8:26 PM

All replies

  • @Stefan - powershell script directly was a better and more secure option than a traditional batch file for these purposes.  The batch file additionally just called powershell anyway, so removing a layer and ensuring we were using the same APIs/methods that we'd ask customers to use was preferred.

    Tim Heuer | Program Manager, XAML | http://timheuer.com/blog | @timheuer

    (if my post has answered your question, please consider using the 'mark as answer' feature in the forums to help others)

    Tuesday, June 5, 2012 8:26 PM
  • Thanks Tim, good to understand why.  Is there a reason that the ps1 file doesn't automatically set the execution policy?

    ...Stefan

    Tuesday, June 5, 2012 8:51 PM
  • @Stefan - it does actually.  See the LaunchElevated command (about line 261).  That operation forces UAC in order to execute it but it does the first time it is ever run.

    Tim Heuer | Program Manager, XAML | http://timheuer.com/blog | @timheuer

    (if my post has answered your question, please consider using the 'mark as answer' feature in the forums to help others)

    Tuesday, June 5, 2012 8:56 PM
  • Tim,

    When I ran it in an unelevated powershop prompt I got this result:

    PS [...]> .\Add-AppDevPackage.ps1
    .\Add-AppDevPackage.ps1 : File [...]\Add-AppDevPackage.ps1 cannot be loaded because running scripts is disabled on this system. For more
    information, see about_Execution_Policies at http://go.microsoft.com/fwlink/?LinkID=135170.
    At line:1 char:1
    + .\Add-AppDevPackage.ps1
    + ~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : SecurityError: (:) [], PSSecurityException
        + FullyQualifiedErrorId : UnauthorizedAccess

    =======

    I got exactly the same result when running elevated.

    Once I manually called set set-executionpolicy remotesigned, it worked unelevated and did request elevation at the appropriate point.  I was just anticipating that if the policy needed to be set that the script would automatically set it, as I had to Google to try and find out what the problem was.

    ...Stefan

    Tuesday, June 5, 2012 9:03 PM
  • @Stefan - this definitely seems odd.  Are scripts disabled on your machine outright from some other means.  I've not had a problem with this at all.  Either way, this appears to be a powershell issue at this point.  I'm guessing something else had previously set a PS setting that disabled at a higher level.

    Tim Heuer | Program Manager, XAML | http://timheuer.com/blog | @timheuer

    (if my post has answered your question, please consider using the 'mark as answer' feature in the forums to help others)

    Tuesday, June 5, 2012 9:20 PM
  • Well I hadn't run powershell since installing Win8. 

    Get the same result on a plain newly installed Windows 8 in VMware, so that appears to be the default setting when Windows is installed.

    ...Stefan

    Tuesday, June 5, 2012 10:34 PM