maxthedork
MIS
At our school, we have at least three different desktop images floating around, and each one has a different Administrator password. Luckily, they all use the same Administrator account. However, I'm trying to create a batch file that will use lsrunas to run a command as the administrator account and automatically pass the password along to it, based on what password is in place. The problem I'm encountering is that lsrunas doesn't return an errorlevel, but runas does. However, runas doesn't allow the command line to pass the password to it either via pipe or redirect ( | or < ). The logic of the script should be something like this:
FOR pass IN (pass1, pass2, pass3) DO
lsrunas /user:administrator /password:%pass% /domain:%COMPUTERNAME% /command:[any command] /runpath:[path of command]
IF %ERRORLEVEL%=="0" THEN BREAK
ELSE
DONE
I'm better at bash shell scripting so forgive me if my syntax is wrong in the FOR statement.
The above WOULD work, except lsrunas always returns ERRORLEVEL=0, whether the password is good or not. runas at least returns ERRORLEVEL=1 when the password is bad, and =0 when the password is good.
Any ideas? Thanks.
FOR pass IN (pass1, pass2, pass3) DO
lsrunas /user:administrator /password:%pass% /domain:%COMPUTERNAME% /command:[any command] /runpath:[path of command]
IF %ERRORLEVEL%=="0" THEN BREAK
ELSE
DONE
I'm better at bash shell scripting so forgive me if my syntax is wrong in the FOR statement.
The above WOULD work, except lsrunas always returns ERRORLEVEL=0, whether the password is good or not. runas at least returns ERRORLEVEL=1 when the password is bad, and =0 when the password is good.
Any ideas? Thanks.