构建事件:复制具有提升权限的文件

时间:2018-01-18 15:09:54

标签: visual-studio-2015

我需要一个可以在Visual Studio的构建后事件命令行中使用的命令,该命令行可以使用提升权限复制文件。

  • runas不是一个选项,因为我的用户可以提升权限。
  • 以管理员身份启动VS也不是一个选项。

最好的方法是什么?

为了完整起见:我想在我的开发机器上自动为SSIS安装CustomComponents。

1 个答案:

答案 0 :(得分:0)

解决方案是使用提升的权限启动PowerShell。 在此PowerShell中,gacutilcopy用于在本地安装CustomComponents。

我在VS2015中使用SQLServer 2017的命令是:

powershell -Command "Start-Process cmd -ArgumentList('/K', 'copy /Y \"$(TargetPath)\" \"C:\Program Files (x86)\Microsoft SQL Server\140\DTS\PipelineComponents\" && \"C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools\gacutil.exe\" /i \"$(TargetPath)\" /f')" -Verb RunAs
相关问题