[wpkg-users] Run script in elevated mode

Rainer Meier r.meier at wpkg.org
Wed Mar 10 18:42:11 CET 2010


Hi Daniel,

On 10.03.2010 17:33, Daniel Dehennin wrote:
> Hello,
> 
> I'm using scripts[1] to install applications, I want to modify my
> install.cmd to wrapp the unattended.cmd call with execute-elevated.js
> 
> I have a problem, tested with win7, in install.cmd :
> - set ELEVATE=\\myserver\PATH\TO\execute-elevated.js
> - replace: call "%INSTALLER_LOC%%INSTALLER%"...
>   with: cscript /Nologo "%ELEVATE%" "%INSTALLER_LOC%%INSTALLER%"...
> 
> When I run: \\myserver\PATH\TO\install.cmd:
> - I get the UAC prompt, I select OK
> - a new cmd window is open and immediatly closed, nothing is installed

Probably you just need to verify the paths. If I am not mistaken INSTALLER_LOC
is set to "%~dp0" which means it points to the path from which you call
install.cmd. So you need to make sure that the script called
("%INSTALLER_LOC%%INSTALLER%") is stored within the same directory. If it's not
you need to change the path to the installer (unattended.cmd).

Please also keep in mind that if you run an elevated command this command will
run with different user credentials. Make sure that you're providing access to
the elevated user to the share as well.


> I put "echo DEBUG > %TMP%" at the top of unattended.cmd and see that
> nothing is created, so the script is not called.

Probably because either the path is wrong or the elevated user does not have
access to the share.

Unfortunately you did not express your use-case. Usually it's much more
convenient to just run wpkg.js elevated so its elevation is inherit by
sub-processes. If you use execute-elevated.js for individual packages you would
have to provide credentials for each single package. Here it's usually not even
required to use execute-elevated.js since you will be able to run wpkg.js
unelevated and installers will usually ask for elevation as needed (unless
Windows does not recognize the installer and it misses a proper manifest).

br,
Rainer



More information about the wpkg-users mailing list