2016-03-20 4 views
5

मैं एक .bat फ़ाइल करना चाहते हैं किसे एक नई विंडो में पावरहेल कैसे शुरू करें। और कंसोल से बाहर निकले बिना .ps1 चलाएं?

  • खुला एक नई विंडो
  • और एक .ps1 स्क्रिप्ट
  • चलाने के लिए और बाहर निकलें और बंद नहीं होती है Powershell
में एक PowerShell कंसोल

start powershell.exe -Command "&'D:\MyToolkit\ToolKit.ps1'" 

हालांकि यह powe बंद कर देता है:

मेरे बल्ले फ़ाइल इस लाइन है स्क्रिप्ट चलाने के बाद rshell।

कोई सलाह? धन्यवाद

+2

'-file powershell -noexit शुरू 'डी: \ MyToolkit \ ToolKit.ps1" ' – Avshalom

+1

धन्यवाद! काम किया! यह काम नहीं करता जब मैंने इसे अंत में रखा लेकिन जब मैंने इसे पहले रखा- कमांडिट ने काम किया – pencilCake

उत्तर

8
start powershell -noexit -file "D:\MyToolkit\ToolKit.ps1" 

इसके अलावा,

बदलें -File इस रूप में -Command क्या आप

2

की जरूरत ही नहीं इस सवाल का मूल पोस्टर के लिए, लेकिन दूसरों जो यहाँ भूमि सकता है जवाब के लिए तलाश के लिए है , सहायता प्रणाली बहुत उपयोगी है और इसे अक्सर अनदेखा किया जाता है।

कमांड/का उपयोग कर? या PowerShellget-help और get-help -full कमांड सभी उपयोगी हैं।

इस मामले में आप जिस आदेश को चलाने के लिए चाहते थे, उस सहायता के लिए शायद आप अपने प्रश्न का उत्तर दे सकते थे, powershell

PowerShell[.exe] [-PSConsoleFile <file> | -Version <version>] 
    [-NoLogo] [-NoExit] [-Sta] [-Mta] [-NoProfile] [-NonInteractive] 
    [-InputFormat {Text | XML}] [-OutputFormat {Text | XML}] 
    [-WindowStyle <style>] [-EncodedCommand <Base64EncodedCommand>] 
    [-File <filePath> <args>] [-ExecutionPolicy <ExecutionPolicy>] 
    [-Command { - | <script-block> [-args <arg-array>] 
        | <string> [<CommandParameters>] } ] 

PowerShell[.exe] -Help | -? | /? 

-NoExit 
    Does not exit after running startup commands. 

... 

-File 
    Runs the specified script in the local scope ("dot-sourced"), so that the 
    functions and variables that the script creates are available in the 
    current session. Enter the script file path and any parameters. 
    File must be the last parameter in the command, because all characters 
    typed after the File parameter name are interpreted 
    as the script file path followed by the script parameters. 

-NoExit - स्टार्टअप आदेशों चलाने के बाद से बाहर नहीं।

-File - ... फ़ाइल आदेश में पिछले पैरामीटर होना चाहिए ...

संबंधित मुद्दे