[英]How do you start a program stored on a UNC share from the command line with parameters?
There's an in-house program we use and it's stored on a UNC share so that updates are transparent. 我们使用的是内部程序,它存储在UNC共享中,以便更新透明。 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. 但我似乎无法让它在CMD或PowerShell中工作或通过快捷方式工作。
Anyone got any ideas? 有人有任何想法吗?
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. 如果要从该进程获取退出代码或其他信息,$ process对象将为您提供实时进程对象。
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. 除非你真的想要使用powershell来完成这项工作。
use %~dp0
in a batch file for the current (unc) path including the trailing \\
在批处理文件中使用%~dp0
作为当前(unc)路径,包括尾随\\
in a powershell script use this for the current (unc) path without trailing \\
在PowerShell脚本中使用它作为当前(unc)路径而不尾随\\
$0 = $myInvocation.MyCommand.Definition
$dp0 = [System.IO.Path]::GetDirectoryName($0)
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. 我只是注意到有一个.CMD文件,它将文件从共享复制到临时目录并在本地运行。
If y'all could just vote this answer up if there's no better solution, that'll work. 如果没有更好的解决方案你们都可以投票给这个答案,那就行了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.