[wpkg-users] Powershell and WPKG
Rainer Meier
r.meier at wpkg.org
Tue Apr 1 23:27:27 CEST 2008
Hi Tomasz,
Tomasz Chmielewski wrote:
> As long as these command work without user interaction when you start
> them as a privileged user, such as Administrator or SYSTEM, these
> commands should also work when started by WPKG.
Right. By default WPKG client executes WPKG with SYSTEM privileges. So
it is allowed to do basically everything. Of course, if wpkg.js is
invoked manually only packages which can be executed with the current
users privileges will success.
By the way - on Windows Vista with active UAC it is pretty hard to
manually invoke WPKG with elevated privileges. At least I noticed that
neither running cscript on an elevated CMD shell nor right-clicking a
*.cmd file (which executes wpkg.js) and run it manually as Administrator
really helps.
To work around this I wrote a small Script (JScript) which allows you to
specify by argument what it has to call with elevated rights. So using
something like
execute-elevated.js myscript.cmd param1 param2
will pop up the usual UAC prompt and then execute myscript.cmd (which
can execute wpkg.js) with elevated user rights.
I also experimented to implement the code to wrapper.js which would
actually call itself with elevated rights before invoking wpkg.js.
Unfortunately I found out that this method erases all custom environment
variables then. As a result even if wrapper.js would be called by a CMD
script which sets SOFTWARE and other variables they are not available to
the finally elevated script.
The only way seems to be to call the batch script itself elevated which
derives this rights to its childs. So I am currently using something like
execute-elevated.js call-wrapper.cmd
and call-wrapper.cmd sets SOFTWARE and other variables before calling
'wrapper.js /synchronize' which seems to be really the only way to
manually invoke WPKG with elevated rights. Without it will simply fail
to install most of the packages (depending on the packages).
I am going to check in this script to SVN soon (after some additional
testing).
> It shouldn't matter if it's PowerShell, Perl, Python etc. (as long as
> the appropriate interpreter is installed).
Well, the interpreter could be defined as a dependency of the package
which means that WPKG (1.0+) will install it BEFORE the actual script is
executed.
br,
Rainer
More information about the wpkg-users
mailing list