{"id":5431,"date":"2012-10-25T12:52:00","date_gmt":"2012-10-25T20:52:00","guid":{"rendered":"http:\/\/www.sapien.com\/blog\/?p=5431"},"modified":"2012-10-25T12:56:59","modified_gmt":"2012-10-25T20:56:59","slug":"revisiting-the-packager-and-command-line-arguments","status":"publish","type":"post","link":"https:\/\/dev.sapien.com\/blog\/2012\/10\/25\/revisiting-the-packager-and-command-line-arguments\/","title":{"rendered":"Revisiting The Packager and Command Line Arguments"},"content":{"rendered":"<p>The original <a href=\"http:\/\/www.sapien.com\/blog\/2010\/02\/09\/primalforms-2009-the-packager-and-command-line-arguments\/\">The Packager and Command line Arguments<\/a> blog article discussed how to pass parameters to a packaged executable. In this article we will revisit this subject and update the functions introduced in the previous article. The article will also cover how to simulate the packager parameters so that you can test your script without having to package it each time. This article\u2019s example uses PowerShell Studio 2012, but it is also applicable to PrimalScript 2012.<\/p>\n<p><strong>Command Line Parsing Functions:<\/strong><\/p>\n<p>The original<font color=\"#008181\"> Convert-ArgumentsToDictionary<\/font> function is no longer valid since PowerShell converts the Dictionary to an array when you return the object down the pipeline. Therefore, the function was updated so the Dictionary is passed to the function as a reference instead of being returned via the pipeline. The new function no longer requires you to call the <font color=\"#008181\">Parse-Commandline<\/font> function beforehand and thus it was renamed to <font color=\"#008181\">Convert-CommandLineToDictionary<\/font> to reflect these changes.<\/p>\n<pre><span style=\"color: #0000ff\">function<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #008080\">Convert-CommandLineToDictionary<\/span><span style=\"color: #000000\"> \r\n{ \r\n    <\/span><span style=\"color: #008000\">&lt;#\r\n    .SYNOPSIS\r\n        Parses and converts the command line of a packaged executable into a Dictionary\r\n\r\n    .DESCRIPTION\r\n        Parses and converts the command line of a packaged executable into a Dictionary\r\n\r\n    .PARAMETER  Dictionary\r\n        The Dictionary to load the value pairs into.\r\n\r\n    .PARAMETER  CommandLine\r\n        The command line of the package executable\r\n\r\n    .PARAMETER  ParamIndicator\r\n        The character used to indicate what is a parameter.\r\n    \r\n    .EXAMPLE\r\n        $Dictionary = New-Object System.Collections.Specialized.StringDictionary\r\n        Convert-CommandLineToDictionary -Dictionary $Dictionary `<br \/> -CommandLine $Commandline  -ParamIndicator '-'\r\n    #&gt;<\/span><span style=\"color: #000000\">\r\n    <\/span><span style=\"color: #0000ff\">Param<\/span><span style=\"color: #000000\">(  [ValidateNotNull()]\r\n            [System.Collections.Specialized.StringDictionary]<\/span><span style=\"color: #8b0000\">$Dictionary<\/span><span style=\"color: #000000\">,\r\n            [string]<\/span><span style=\"color: #8b0000\">$CommandLine<\/span><span style=\"color: #000000\">, \r\n            [char] <\/span><span style=\"color: #8b0000\">$ParamIndicator<\/span><span style=\"color: #000000\">) \r\n\r\n    <\/span><span style=\"color: #8b0000\">$Params<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #008080\">Parse-Commandline<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #8b0000\">$CommandLine<\/span><span style=\"color: #000000\">\r\n    \r\n    <\/span><span style=\"color: #0000ff\">for<\/span><span style=\"color: #000000\">(<\/span><span style=\"color: #8b0000\">$index<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #000000\">0<\/span><span style=\"color: #000000\">; <\/span><span style=\"color: #8b0000\">$index<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000ff\">-lt<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #8b0000\">$Params<\/span><span style=\"color: #000000\">.Count; <\/span><span style=\"color: #8b0000\">$index<\/span><span style=\"color: #0000ff\">++<\/span><span style=\"color: #000000\">) \r\n    { \r\n        [string]<\/span><span style=\"color: #8b0000\">$param<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #8b0000\">$Params<\/span><span style=\"color: #000000\">[<\/span><span style=\"color: #8b0000\">$index<\/span><span style=\"color: #000000\">] \r\n        <\/span><span style=\"color: #008000\">#Clear the values <\/span><span style=\"color: #000000\">\r\n        <\/span><span style=\"color: #8b0000\">$key<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #ff0000\">\"\"<\/span><span style=\"color: #000000\"> \r\n        <\/span><span style=\"color: #8b0000\">$value<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #ff0000\">\"\"<\/span><span style=\"color: #000000\"> \r\n\r\n        <\/span><span style=\"color: #0000ff\">if<\/span><span style=\"color: #000000\">(<\/span><span style=\"color: #8b0000\">$param<\/span><span style=\"color: #000000\">.StartsWith(<\/span><span style=\"color: #8b0000\">$ParamIndicator<\/span><span style=\"color: #000000\">)) \r\n        { \r\n            <\/span><span style=\"color: #008000\">#Remove the indicator <\/span><span style=\"color: #000000\">\r\n            <\/span><span style=\"color: #8b0000\">$key<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #8b0000\">$param<\/span><span style=\"color: #000000\">.Remove(<\/span><span style=\"color: #000000\">0<\/span><span style=\"color: #000000\">,<\/span><span style=\"color: #000000\">1<\/span><span style=\"color: #000000\">) \r\n            <\/span><span style=\"color: #0000ff\">if<\/span><span style=\"color: #000000\">(<\/span><span style=\"color: #8b0000\">$index<\/span><span style=\"color: #000000\">  <\/span><span style=\"color: #0000ff\">+<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #000000\">1<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000ff\">-lt<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #8b0000\">$Params<\/span><span style=\"color: #000000\">.Count) \r\n            { \r\n                <\/span><span style=\"color: #008000\">#Check if the next Argument is a parameter <\/span><span style=\"color: #000000\">\r\n                [string]<\/span><span style=\"color: #8b0000\">$param<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #8b0000\">$Params<\/span><span style=\"color: #000000\">[<\/span><span style=\"color: #8b0000\">$index<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000ff\">+<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #000000\">1<\/span><span style=\"color: #000000\">] \r\n                <\/span><span style=\"color: #0000ff\">if<\/span><span style=\"color: #000000\">(<\/span><span style=\"color: #8b0000\">$param<\/span><span style=\"color: #000000\">.StartsWith(<\/span><span style=\"color: #8b0000\">$ParamIndicator<\/span><span style=\"color: #000000\">) <\/span><span style=\"color: #0000ff\">-ne<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #8b0000\">$true<\/span><span style=\"color: #000000\"> ) \r\n                { \r\n                    <\/span><span style=\"color: #008000\">#If it isn\u2019t a parameter then set it as the value <\/span><span style=\"color: #000000\">\r\n                    <\/span><span style=\"color: #8b0000\">$value<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #8b0000\">$param<\/span><span style=\"color: #000000\"> \r\n                    <\/span><span style=\"color: #8b0000\">$index<\/span><span style=\"color: #0000ff\">++<\/span><span style=\"color: #000000\"> \r\n                } \r\n            } \r\n            <\/span><span style=\"color: #8b0000\">$Dictionary<\/span><span style=\"color: #000000\">[<\/span><span style=\"color: #8b0000\">$key<\/span><span style=\"color: #000000\">] <\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #8b0000\">$value<\/span><span style=\"color: #000000\"> \r\n        }<\/span><span style=\"color: #008000\">#else skip <\/span><span style=\"color: #000000\">\r\n    } \r\n}<\/span><\/pre>\n<p>The following is the updated <font color=\"#008181\">Parse-Commandline<\/font> function:<\/p>\n<pre><span style=\"color: #0000ff\">function<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #008080\">Parse-Commandline<\/span><span style=\"color: #000000\"> \r\n{ \r\n<\/span><span style=\"color: #008000\">&lt;#\r\n    .SYNOPSIS\r\n        Parses the command line of a package executable\r\n\r\n    .DESCRIPTION\r\n        Parses the command line of a package executable\r\n\r\n    .PARAMETER  Commandline\r\n        The command line of the package executable\r\n\r\n    .EXAMPLE\r\n        $arguments = Parse-Commandline -Commandline $Commandline\r\n\r\n    .INPUTS\r\n        System.String\r\n\r\n    .OUTPUTS\r\n        System.Collections.Specialized.StringCollection\r\n#&gt;<\/span><span style=\"color: #000000\">\r\n\r\n    [OutputType([System.Collections.Specialized.StringCollection])]\r\n    <\/span><span style=\"color: #0000ff\">Param<\/span><span style=\"color: #000000\">([string]<\/span><span style=\"color: #8b0000\">$CommandLine<\/span><span style=\"color: #000000\">) \r\n    \r\n    <\/span><span style=\"color: #8b0000\">$Arguments<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000ff; font-weight: bold\">New-Object<\/span><span style=\"color: #000000\"> System.Collections.Specialized.StringCollection \r\n    \r\n    <\/span><span style=\"color: #0000ff\">if<\/span><span style=\"color: #000000\">(<\/span><span style=\"color: #8b0000\">$CommandLine<\/span><span style=\"color: #000000\">)\r\n    {\r\n        <\/span><span style=\"color: #008000\">#Find First Quote <\/span><span style=\"color: #000000\">\r\n        <\/span><span style=\"color: #8b0000\">$index<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #8b0000\">$CommandLine<\/span><span style=\"color: #000000\">.IndexOf(<\/span><span style=\"color: #ff0000\">'\"'<\/span><span style=\"color: #000000\">) \r\n\r\n        <\/span><span style=\"color: #0000ff\">while<\/span><span style=\"color: #000000\"> ( <\/span><span style=\"color: #8b0000\">$index<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000ff\">-ne<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000ff\">-<\/span><span style=\"color: #000000\">1<\/span><span style=\"color: #000000\">) \r\n        {<\/span><span style=\"color: #008000\">#Continue as along as we find a quote <\/span><span style=\"color: #000000\">\r\n            <\/span><span style=\"color: #008000\">#Find Closing Quote <\/span><span style=\"color: #000000\">\r\n            <\/span><span style=\"color: #8b0000\">$closeIndex<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #8b0000\">$CommandLine<\/span><span style=\"color: #000000\">.IndexOf(<\/span><span style=\"color: #ff0000\">'\"'<\/span><span style=\"color: #000000\">,<\/span><span style=\"color: #8b0000\">$index<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000ff\">+<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #000000\">1<\/span><span style=\"color: #000000\">) \r\n            <\/span><span style=\"color: #0000ff\">if<\/span><span style=\"color: #000000\">(<\/span><span style=\"color: #8b0000\">$closeIndex<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000ff\">-eq<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000ff\">-<\/span><span style=\"color: #000000\">1<\/span><span style=\"color: #000000\">) \r\n            { \r\n                <\/span><span style=\"color: #0000ff\">break<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #008000\">#Can\u2019t find a match <\/span><span style=\"color: #000000\">\r\n            } \r\n            <\/span><span style=\"color: #8b0000\">$value<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #8b0000\">$CommandLine<\/span><span style=\"color: #000000\">.Substring(<\/span><span style=\"color: #8b0000\">$index<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000ff\">+<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #000000\">1<\/span><span style=\"color: #000000\">,<\/span><span style=\"color: #8b0000\">$closeIndex<\/span><span style=\"color: #000000\"> \u2013 (<\/span><span style=\"color: #8b0000\">$index<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000ff\">+<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #000000\">1<\/span><span style=\"color: #000000\">)) \r\n            [void]<\/span><span style=\"color: #8b0000\">$Arguments<\/span><span style=\"color: #000000\">.Add(<\/span><span style=\"color: #8b0000\">$value<\/span><span style=\"color: #000000\">) \r\n            <\/span><span style=\"color: #8b0000\">$index<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #8b0000\">$closeIndex<\/span><span style=\"color: #000000\"> \r\n\r\n            <\/span><span style=\"color: #008000\">#Find First Quote <\/span><span style=\"color: #000000\">\r\n            <\/span><span style=\"color: #8b0000\">$index<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #8b0000\">$CommandLine<\/span><span style=\"color: #000000\">.IndexOf(<\/span><span style=\"color: #ff0000\">'\"'<\/span><span style=\"color: #000000\">,<\/span><span style=\"color: #8b0000\">$index<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000ff\">+<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #000000\">1<\/span><span style=\"color: #000000\">) \r\n        } \r\n    }\r\n    <\/span><span style=\"color: #0000ff\">return<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #8b0000\">$Arguments<\/span><span style=\"color: #000000\"> \r\n}<\/span><\/pre>\n<p>&nbsp;<\/p>\n<p><font size=\"3\"><strong>Simulating Packager Command line:<\/strong><\/font><\/p>\n<p>There are times you might want to test your command line inputs but don\u2019t want to make debugging more difficult by having to package the script. As an alternative, you can simulate the packager\u2019s command line and pass it as an argument to the debugger, thus bypassing the packaging stage.<\/p>\n<p><strong>Preparation:<\/strong><\/p>\n<p>A PowerShell Studio project is used as a basis for this example, but the same steps can apply to a single Form file (GUI Script) or a typical script. <\/p>\n<p><em>Step 1: Define a parameter to accept the test command line<\/em><\/p>\n<p>In the project\u2019s startup.pfs file we define a parameter block as follows:<\/p>\n<pre><span style=\"color: #0000ff\">Param<\/span><span style=\"color: #000000\"> (<\/span><span style=\"color: #8b0000\">$TestCommandline<\/span><span style=\"color: #000000\">)\r\n<\/span><\/pre>\n<p>Note: Parameter blocks should always be defined at the top of the script. The same hold true if you are working with a Form.<\/p>\n<p>&nbsp;<\/p>\n<p><em>Step 2: Replacing $CommandLine variable with the test variable<\/em><\/p>\n<p>The packager creates the $CommandLine variable which contains the command line arguments that were used to call the packaged executable. In this case, we want to use a simulated command line but at the same time ensure our script will still run when packaged. In order to accommodate this, one must check if the $CommandLine variable has any contents before replacing its value. <\/p>\n<p>In the case of a project, we add the check in the project\u2019s Main function and only replace the $Commandline variable if its content is empty or null. Afterwards you can use the parsing functions to handle the $Commandline variable.<\/p>\n<pre><span style=\"color: #0000ff\">function<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #008080\">Main<\/span><span style=\"color: #000000\"> {\r\n    <\/span><span style=\"color: #0000ff\">Param<\/span><span style=\"color: #000000\"> ([String]<\/span><span style=\"color: #8b0000\">$Commandline<\/span><span style=\"color: #000000\">)\r\n    \r\n    <\/span><span style=\"color: #0000ff\">if<\/span><span style=\"color: #000000\">(<\/span><span style=\"color: #0000ff\">-not<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #8b0000\">$Commandline<\/span><span style=\"color: #000000\">)\r\n    {\r\n        <\/span><span style=\"color: #8b0000\">$Commandline<\/span><span style=\"color: #000000\">  <\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #8b0000\">$TestCommandline<\/span><span style=\"color: #000000\">    \r\n    }\r\n    <\/span><span style=\"color: #8b0000\">$Dictionary<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000ff; font-weight: bold\">New-Object<\/span><span style=\"color: #000000\"> System.Collections.Specialized.StringDictionary\r\n    Convert-CommandLineToDictionary <\/span><span style=\"color: #0000ff\">-<\/span><span style=\"color: #000000\">Dictionary <\/span><span style=\"color: #8b0000\">$Dictionary<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000ff\">-<\/span><span style=\"color: #000000\">CommandLine <\/span><span style=\"color: #8b0000\">$Commandline<\/span><span style=\"color: #000000\">  <\/span><span style=\"color: #0000ff\">-<\/span><span style=\"color: #000000\">ParamIndicator <\/span><span style=\"color: #ff0000\">'-'<\/span><span style=\"color: #000000\">\r\n    <\/span><span style=\"color: #008000\">#Output the original command line string <\/span><span style=\"color: #000000\">\r\n    <\/span><span style=\"color: #ff0000\">\"Command Line: {0}`r`n\"<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000ff\">-f<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #8b0000\">$CommandLine<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000ff\">|<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000ff; font-weight: bold\">Write-Output<\/span><span style=\"color: #000000\">     <\/span><span style=\"color: #008000\">#Display all the parsed command line values:<\/span><span style=\"color: #000000\">\r\n    <\/span><span style=\"color: #8b0000\">$Dictionary<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000ff\">|<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000ff; font-weight: bold\">Format-Table<\/span><span style=\"color: #000000\"> @{label<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #ff0000\">\"Key\"<\/span><span style=\"color: #000000\">;Expression<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #000000\">{<\/span><span style=\"color: #8b0000\">$_<\/span><span style=\"color: #000000\">.Key}},@{label<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #ff0000\">\"Value\"<\/span><span style=\"color: #000000\">;Expression<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #000000\">{<\/span><span style=\"color: #8b0000\">$_<\/span><span style=\"color: #000000\">.Value}} <\/span><span style=\"color: #0000ff\">|<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000ff; font-weight: bold\">Write-Output<\/span><span style=\"color: #000000\">\r\n    \r\n    <\/span><span style=\"color: #0000ff\">..<\/span><span style=\"color: #000000\">.<\/span><\/pre>\n<p>&nbsp;<\/p>\n<p>In normal scripts, insert the check right after the parameter definition. <\/p>\n<p>For Form files you might want to consider calling the parsing functions in the Form\u2019s Load event.<\/p>\n<p>&nbsp;<\/p>\n<p><em>Step 3: Format the input to match that of the packager<\/em><\/p>\n<p>In the original article we discussed how the $Commandline variable contains the parameters passed to the packaged exe. The packager\u2019s $Commandline variable has each parameter and parameter value surrounded by individual double quotes. <\/p>\n<p>For example:<\/p>\n<p>mypackage.exe -Parameter1 Value1 -Parameter2 Value2 <\/p>\n<p>Results in $CommandLine variable containing the following string: <\/p>\n<blockquote>\n<p>\u201c-Parameter1\u201d \u201cValue1\u201d \u201c-Parameter2\u201d \u201cValue2\u201d<\/p>\n<\/blockquote>\n<p>In order to simulate the packager arguments you must alter your test parameter input as follows: <\/p>\n<p>1. Wrap each individual parameter and parameter value in Double Quotes in order to mirror the packager\u2019s behavior. <\/p>\n<p>2. Wrap the whole parameters \/ values within <strong>single quotes<\/strong>, so that PowerShell treats it as a single string: <\/p>\n<blockquote>\n<p><font color=\"#ff0000\"><strong>\u2018<\/strong><\/font>\u201c-Parameter1\u201d \u201cValue1\u201d \u201c-Parameter2\u201d \u201cValue2\u201d<font color=\"#ff0000\"><strong>\u2019<\/strong><\/font> <\/p>\n<p>If you do not make the parameters into a single string, the TestCommandline variable would only contain the first item (in this case would be \u201c-Parameter1\u201d). <\/p>\n<\/blockquote>\n<p>Now you are ready to simulate and test the packager command line! <\/p>\n<p>When the script is executed, the $Commandline variable will be replaced with the $TestCommandline\u2019s contents and you will be able to process the results correctly: <\/p>\n<p><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px\" title=\"Output\" border=\"0\" alt=\"Output\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2012\/10\/Output.png\" width=\"655\" height=\"247\"> <\/p>\n<p><strong>Debugging Tip:<\/strong> <\/p>\n<p>In some instances you want to use the same test parameters every time you debug a particular script; therefore, we recommend using the DebugParameters meta-tag at the top of the script:<\/p>\n<pre><span style=\"color: #008000\"># %DebugParameters% = '\"-Parameter1\" \"Value1\" \"-Parameter2\" \"Value2\"' <\/span><\/pre>\n<p>Now when you debug the script, the specified parameters will be automatically selected. <\/p>\n<p><strong>New Snippet:<\/strong> <\/p>\n<p>Snippets containing the command line parsing functions are included in <a href=\"http:\/\/www.sapien.com\/software\/powershell_studio\" target=\"_blank\">PowerShell Studio 2012<\/a> v3.1.9 or greater and <a href=\"http:\/\/www.sapien.com\/software\/primalscript\" target=\"_blank\">PrimalScript 2012<\/a> v6.5.134 or greater.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The original The Packager and Command line Arguments blog article discussed how to pass parameters to a packaged executable. In this article we will revisit this subject and update the functions introduced in the previous article. The article will also cover how to simulate the packager parameters so that you can test your script without [&hellip;]<\/p>\n","protected":false},"author":10,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[283,705,410,25],"tags":[294,282,437,152,28,1016,37,782,302],"class_list":["post-5431","post","type-post","status-publish","format-standard","hentry","category-howto","category-powershell-studio-2012","category-primalscript-software-news","category-windows-powershell","tag-commandline","tag-functions","tag-packager","tag-parameter","tag-powershell","tag-powershell-studio","tag-primalscript","tag-script-to-exe","tag-snippet"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/5431","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/users\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/comments?post=5431"}],"version-history":[{"count":16,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/5431\/revisions"}],"predecessor-version":[{"id":5484,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/5431\/revisions\/5484"}],"wp:attachment":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/media?parent=5431"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/categories?post=5431"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/tags?post=5431"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}