• 请不要在回答技术问题时复制粘贴 AI 生成的内容
youla
V2EX  ›  程序员

请问 Powershell 怎么直接拼接参数执行命令?

  •  
  •   youla · Sep 13, 2020 · 2203 views
    This topic created in 2077 days ago, the information mentioned may be changed or developed.
    powershell [System.Windows.Forms.SendKeys]::SendWait("{Enter}")
    

    不熟悉 Powershell 的语法,暂时需要做一个这样的功能。

    伸个爪,求教。

    3 replies    2020-09-14 13:42:35 +08:00
    iamverylovely
        1
    iamverylovely  
       Sep 14, 2020
    ```powershell

    powershell -Command '[void] [System.Reflection.Assembly]::LoadWithPartialName(\"System.Windows.Forms\");[System.Windows.Forms.SendKeys]::SendWait(\"你似不似懒\")'


    ```
    Tumblr
        3
    Tumblr  
       Sep 14, 2020
    从昨晚看到同在,还是没明白楼主的具体需求。
    在提供的这一句来看,就是发送按键啊。

    PowerShell 本身就是直接执行的,要么写脚本传递参数,要么在控制台上敲,要么集成到一个 GUI 里去并在 GUI 中监听和响应事件(按钮、按键等)。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3124 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 06:32 · PVG 14:32 · LAX 23:32 · JFK 02:32
    ♥ Do have faith in what you're doing.