Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Build events: copy file with elevated rights

I need a command that I can use in Visual Studio's Post-build event command line that can copy a file using elevated rights.

  • runas is not an option as my user can elevate privileges.
  • starting VS as admin is also not an option.

What is the best way?

For the sake of completeness: I want to install CustomComponents for SSIS automatically on my development machine.

like image 448
Dennis Guse Avatar asked Sep 10 '25 13:09

Dennis Guse


1 Answers

The solution is to start a powershell with elevated privileges. In this powershell a gacutil und copy are used to install the CustomComponents locally.

The command I use in VS2015 with SQLServer 2017 is:

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
like image 197
Dennis Guse Avatar answered Sep 13 '25 13:09

Dennis Guse



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!