<p>For example; with the old command prompt it would be:</p>

<pre><code>cmd.exe /k mybatchfile.bat
</code></pre>

[{'answer_id': 14313, 'author': 'Matt Hamilton', 'author_id': 615, 'author_profile': 'https://Stackoverflow.com/users/615', 'pm_score': 6, 'selected': True, 'text': '<p>Drop into a cmd instance (or indeed PowerShell itself) and type this:</p>\n\n<pre><code>powershell -?\n</code></pre>\n\n<p>You\'ll see that powershell.exe has a "-noexit" parameter which tells it not to exit after executing a "startup command".</p>\n'}, {'answer_id': 5346936, 'author': 'john', 'author_id': 665321, 'author_profile': 'https://Stackoverflow.com/users/665321', 'pm_score': -1, 'selected': False, 'text': '<p>I am sure that you already figure this out but I just post it</p>\n\n<pre><code>$CreateDate = (Get-Date -format \'yyyy-MM-dd hh-mm-ss\')\n\n$RemoteServerName ="server name"\n$process = [WMICLASS]"\\\\$RemoteServerName\\ROOT\\CIMV2:win32_process"  \n$result = $process.Create("C:\\path to a script\\test.bat") \n$result | out-file -file "C:\\some path \\Log-$CreatedDate.txt"\n</code></pre>\n'}, {'answer_id': 20060082, 'author': 'deadlydog', 'author_id': 602585, 'author_profile': 'https://Stackoverflow.com/users/602585', 'pm_score': 4, 'selected': False, 'text': '<p>When running PowerShell.exe just provide the <strong>-NoExit</strong> switch like so:</p>\n\n<pre><code>PowerShell -NoExit -File "C:\\SomeFolder\\SomePowerShellScript.ps1"\n\nPowerShell -NoExit -Command "Write-Host \'This window will stay open.\'"\n</code></pre>\n\n<p>Or if you want to run a file and then run a command and have the window stay open, you can do something like this:</p>\n\n<pre><code>PowerShell -NoExit "&amp; \'C:\\SomeFolder\\SomePowerShellScript.ps1\'; Write-Host \'This window will stay open.\'"\n</code></pre>\n\n<p>The <strong>-Command</strong> parameter is implied if not provided, and here we use the <strong>&amp;</strong> to call the PowerShell script, and the <strong>;</strong> separates the PowerShell commands.</p>\n\n<p>Also, at the bottom of <a href="http://blog.danskingdom.com/fix-problem-where-windows-powershell-cannot-run-script-whose-path-contains-spaces/" rel="noreferrer">my blog post</a> I show a quick registry change you can make in order to always have PowerShell remain open after executing a script/command, so that you don\'t need to always explicitly provide the -NoExit switch all the time.</p>\n'}]
['https://Stackoverflow.com/questions/14300', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/887/']