Core Function RunAsSet
(Created page with "<pre> RunAsSet( <user>, <domain>, <password>, <options> ) </pre> === Description === Initialise a set of user credentials to use during Run and RunWait operations. === Paramet...")
Newer edit →
Revision as of 10:38, 29 November 2011
RunAsSet( <user>, <domain>, <password>, <options> )
Contents |
Description
Initialise a set of user credentials to use during Run and RunWait operations.
Parameters
username
Optional; The user name to use.
domain
Optional; The domain name to use.
password
Optional; The password to use.
options
Optional;
0 = do not load the user profile
1 = (default) load the user profile
2 = use for net credentials only
Return Value
Returns 0 if the operating system does not support this function.
Otherwise returns 1--regardless of success. (If the login information was invalid, subsequent Run/RunWait commands will fail....)
Remarks
This function allows subsequent Run and RunWait functions to run as a different user (e.g. Administrator).
The "Secondary Logon service" or "RunAs service" must not be disabled if you want this function to work.
To unset the RunAs details, use the function with no parameters: RunAsSet().
Example
// Set the RunAs parameters to use local adminstrator account RunAsSet("Administrator", @DOMAIN, "adminpassword"); // Run registry editor as admin RunWait("regedit.exe"); // Reset user's permissions RunAsSet();