In a PowerShell script, I have to call the batch file in a larger window. Therefore i do
Start-Process my.bat -Verb runas
Now it my.batexpects some of the ENV variables that I set in the original window to be present. However, since the elevated window runs as admin, these variables, which I set as a regular user, do not appear in the admin window.
my.bat
Is there any way to set ENV vars in admin window before calling my.bat?
, , . . , script, , script my.bat.
IIRC "runas" PowerShell, script :
@echo off set "VARIABLE1=%1" set "VARIABLE2=%2" call "C:\path\to\my.bat"
:
Start-Process .\wrapper.ps1 -ArgumentList 'foo', 'bar' -Verb runas
Source: https://habr.com/ru/post/1016631/More articles:How to show what a package requires in Composer - composer-phpStart-Process -WorkingDirectory as administrator does not set location - powershellHow to integrate Laravel 5.4 with Angular 4 - jsonКак установить значение по умолчанию в response-select - default-valueClever indentation of brackets (brackets) in sublime text 2 - sublimetext2Get value from "Bootstrap-Select" - javascriptHow to make a section optional when matching with additional data in the Word OpenXml Part? - ms-wordUsing multiple custom classes with Pipeline sklearn (Python) - pythonDijkstra's Algorithm with Chebyshev Distance - algorithmRounding error in variable information from RxSpssData - rAll Articles