ph_runasuser1 PowerHome formula function
Description
Executes an application as a specific
user.
Syntax
ph_runasuser1 ( domain, user, pass, appl,
currdir, vis, async, wait )
Argument |
Description |
domain |
String. The domain of the userid you're
attempting to run as. Typically you would enter an empty string unless
you're trying to authenticate over a corporate network. |
user |
String. The userid to run the program
as. |
pass |
String. The password for the
userid. |
appl |
String. The full path and filename of
the application to execute. |
currdir |
String. The default directory you wish
the application to start from. |
vis |
Integer. Whether the application should
be visible or not. Use 0 for the app to run in the background without a
visible window. Use 1 to run the application normally. |
async |
Integer. Whether the application runs
asynchronously or not. Use 0 to run the app synchronously and have
PowerHome wait until the app completes or the wait parameter is exceeded.
Use 1 to have the app run asynchronously and return control immediately to
PowerHome. |
wait |
Long. The time in milliseconds to wait
for an app that is run synchronously (async parameter is 0) to complete.
If the app is not done within the specified time, the function will
return. Use a negative value in order to wait indefinitely.
|
Return value
Long. Returns the status of the operation
or the exit code from the application. - 1 is returned if the PowerHome cannot
login as the specified domain, user, and pass. - 2 is returned if PowerHome
cannot launch the application as the specified user. If the async parameter = 1
and the application was successfully launched, then 0 will be returned. If the
async parameter = 0 and the application is still running when the wait parameter
expires, then 259 will be returned signifying that the application is still
running. If the application completes before the wait parameter expires, then
the return value will be the exit code returned by the application.
Usage
Use this function (or the ph_runasuser
function) to execute an application as a specific user. Both the ph_runasuser and ph_runasuser1 functions do the same thing but each uses a
different mechanism. Depending upon the system, one function or the other may
have better results. The ph_runasuser function uses CreateProcessWithLogon while the ph_runasuser1 function uses CreateProcessAsUser
.
Examples
The following examples demonstrate typical
syntax/usage for this function.
ph_runasuser1("","administrator","adminpass","regsvr32.exe
phuirt.dll","c:\powerhome",1,0,5000)