[使用Powershell启动具有参数的程序以获取管理员特权

问题描述 投票:1回答:1

我有一个.bat文件,像这样。但是我不能通过此命令以管理员身份运行SeqEdit.exe。我研究了Powershell,但我不知道如何正确使用它。请帮助我将此命令转换为powershell命令格式。预先谢谢你。

@echo off
cd "C:\Program Files\National Instruments\TestStand 2016\Bin"
start /min "" SeqEdit.exe /runEntryPoint "Test UUTs" "C:\Peritec\111 Renesas for Oita\SLT Test System_ver109c\Sequence\SLT Test_Main_Ver2016.2.seq"

exit 
powershell batch-file command privileges administrator
1个回答
0
投票

您可以使用此:

Set-Location "C:\Program Files\National Instruments\TestStand 2016\Bin" 
Start-Process -FilePath ".\SeqEdit.exe" -ArgumentList "/runEntryPoint 'Test UUTs' 'C:\Peritec\111 Renesas for Oita\SLT Test System_ver109c\Sequence\SLT Test_Main_Ver2016.2.seq'" -Verb RunAs -WindowStyle minimized

如果要使用cmd进行此操作,请首先创建此批处理文件:

@echo off
echo Set objShell = CreateObject("Shell.Application") > %temp%\sudo.tmp.vbs 
echo args = Right("%*", (Len("%*") - Len("%1"))) >> %temp%\sudo.tmp.vbs 
echo objShell.ShellExecute "%1", args, "", "runas" >> %temp%\sudo.tmp.vbs 
cscript //nologo %temp%\sudo.tmp.vbs

现在从另一个批处理文件运行:

pushd "The location of seqedit.exe"
TheFullPathAndNameOfAboveBatchFile seqedit.exe "arguments" "arguments"
© www.soinside.com 2019 - 2024. All rights reserved.