如何从命令行使用参数启动存储在 UNC 共享上的程序?

发布于 2024-07-09 07:11:21 字数 212 浏览 6 评论 0原文

我们使用一个内部程序,它存储在 UNC 共享上,因此更新是透明的。 我想向它提供一些命令行参数,如下所示:

\\server\share\in_house_thingy.exe myusername mypassword

但我似乎无法让它在 CMD 或 PowerShell 中或通过快捷方式工作。

有人有什么想法吗?

There's an in-house program we use and it's stored on a UNC share so that updates are transparent. I'd like to supply it some command line parameters like so:

\\server\share\in_house_thingy.exe myusername mypassword

But I can't seem to get it to work in either CMD or PowerShell or via a shortcut.

Anyone got any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

我是男神闪亮亮 2024-07-16 07:11:21

您可以使用:

$app = '\\server\share\in_house_thingy.exe'
$arguments = 'myusername mypassword'
$process = [System.Diagnostics.Process]::Start($app, $arguments)

如果您想从该进程获取退出代码或其他信息,$process 对象将为您提供一个实时进程对象。

You could use:

$app = '\\server\share\in_house_thingy.exe'
$arguments = 'myusername mypassword'
$process = [System.Diagnostics.Process]::Start($app, $arguments)

The $process object will give you a live process object if you want to get an exit code or other information from that process.

じ违心 2024-07-16 07:11:21

对于快捷方式,将目标更改为:

"\\server\share\in_house_thingy.exe" myusername mypassword

除非您确实想要使用 powershell 来完成此操作。

For a shortcut, change the target to be like:

"\\server\share\in_house_thingy.exe" myusername mypassword

unless you really do want to have to use powershell to make this work.

音盲 2024-07-16 07:11:21

在批处理文件中使用 %~dp0 作为当前 (unc) 路径,包括

powershell 脚本中的尾随 \ 将此用于当前 (unc) 路径,不带尾随 \

$0 = $myInvocation.MyCommand.Definition
$dp0 = [System.IO.Path]::GetDirectoryName($0)

use %~dp0 in a batch file for the current (unc) path including the trailing \

in a powershell script use this for the current (unc) path without trailing \

$0 = $myInvocation.MyCommand.Definition
$dp0 = [System.IO.Path]::GetDirectoryName($0)
倾城月光淡如水﹏ 2024-07-16 07:11:21

我刚刚注意到有一个 .CMD 文件将文件从共享复制到临时目录并在本地运行。

如果没有更好的解决方案,你们都可以投票赞成这个答案,那就行了。

I just noticed that there's a .CMD file that's copying the file from the share to the temp directory and running it locally.

If y'all could just vote this answer up if there's no better solution, that'll work.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文