Thanks everyone and thanks to drillsergeant for the link.
Here is how I finally made it work.
The login script calls runas.kix
Code:
RUN "runas /user:Admin cmd"
$ReturnCode = SendKeys("password")
$ReturnCode = SendKeys("{ENTER}")
SHELL '%COMSPEC% /C "pwrcfg.bat"'
SLEEP 3
$ReturnCode = Sendkeys("exit")
$ReturnCode = SendKeys("{ENTER}")
RUN "cmd"
$ReturnCode = SendKeys("powercfg /Create ")
$ReturnCode = SendKeys('"')
$ReturnCode = SendKeys("Power_Scheme")
$ReturnCode = SendKeys('"')
$ReturnCode = SendKeys("{ENTER}")
$ReturnCode = SendKeys("powercfg /SetActive ")
$ReturnCode = SendKeys('"')
$ReturnCode = SendKeys("Power_Scheme")
$ReturnCode = SendKeys('"')
$ReturnCode = SendKeys("{ENTER}")
$ReturnCode = SendKeys("powercfg /Change ")
$ReturnCode = SendKeys('"')
$ReturnCode = SendKeys("Power_Scheme /monitor-timeout-ac 15")
$ReturnCode = SendKeys('"')
$ReturnCode = SendKeys("{ENTER}")
$ReturnCode = SendKeys("powercfg /Hibernate off")
$ReturnCode = SendKeys("{ENTER}")
$ReturnCode = SendKeys("exit")
$ReturnCode = SendKeys("{ENTER}")
runas.kix calls pwrcfg.bat
Code:
setacl.exe -on "\\%computername%\HKLM\SOFTWARE\MICROSOFT\Windows\CurrentVersion\Controls Folder\PowerCfg\GlobalPowerPolicy" -ot reg -actn ace -ace "n:%computername%\users;p:full"
setacl.exe -on "\\%computername%\HKLM\SOFTWARE\MICROSOFT\Windows\CurrentVersion\Controls Folder\PowerCfg\PowerPolicies" -ot reg -actn ace -ace "n:%computername%\users;p:full"
setacl.exe -on "\\%computername%\HKLM\SOFTWARE\MICROSOFT\Windows\CurrentVersion\Controls Folder\PowerCfg" -ot reg -actn ace -ace "n:%computername%\users;p:full"
I just need to have pwrcfg.bat, runas.kix, and SetACL.exe in the same directory. I'm also going to have the script to remove the permissions once the changes have been made.
P.S. Before I deploy runas.kix I plan on kixcrypting it so no one can trace it down and view the password.