V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
youla
V2EX  ›  程序员

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

  •  
  •   youla · 2020-09-13 22:15:08 +08:00 · 1662 次点击
    这是一个创建于 1291 天前的主题,其中的信息可能已经有所发展或是发生改变。
    powershell [System.Windows.Forms.SendKeys]::SendWait("{Enter}")
    

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

    伸个爪,求教。

    3 条回复    2020-09-14 13:42:35 +08:00
    iamverylovely
        1
    iamverylovely  
       2020-09-14 10:29:01 +08:00
    ```powershell

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


    ```
    iamverylovely
        2
    iamverylovely  
       2020-09-14 10:32:25 +08:00
    Tumblr
        3
    Tumblr  
       2020-09-14 13:42:35 +08:00
    从昨晚看到同在,还是没明白楼主的具体需求。
    在提供的这一句来看,就是发送按键啊。

    PowerShell 本身就是直接执行的,要么写脚本传递参数,要么在控制台上敲,要么集成到一个 GUI 里去并在 GUI 中监听和响应事件(按钮、按键等)。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3229 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 13:53 · PVG 21:53 · LAX 06:53 · JFK 09:53
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.