Lenovo ThinkPad L540 (English) Power Manager Deployment Guide - Page 60

Sample script, ImportPowerPlan, ControlPowerPlan

Page 60 highlights

Sample script This section provides a sample script showing how to use the ImportPowerPlan command line and the ControlPowerPlan command line in the logon script. PowerPlanDeployment.bat @ECHO OFF SETLOCAL IF .%PROCESSOR_ARCHITECTURE%.==.x86. ( SET PMDllName=PWMTR32V.DLL SET PMREG_INFO="HKEY_LOCAL_MACHINE\SOFTWARE\Lenovo\PWRMGRV\InstallInfo" SET PMREG_PATH="HKEY_LOCAL_MACHINE\SOFTWARE\Lenovo\PWRMGRV\Path" ) ELSE ( SET PMDllName=PWMTR64V.DLL SET PMREG_INFO="HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Lenovo\PWRMGRV\InstallInfo" SET PMREG_PATH="HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Lenovo\PWRMGRV\Path" ) FOR /F "tokens=1,2*" %%i in ('reg query %PMREG_INFO% /v "PWRMGRVersion"' ) DO ( IF "%%i"=="PWRMGRVersion" ( SET PM_Version=%%k ) ) FOR /F "tokens=1-3 delims=." %%i in ('echo %PM_Version%') DO ( SET PM_MAJORVER=%%i SET PM_MINORVER=%%j ) FOR /F "tokens=1,2*" %%i in ('reg query %PMREG_PATH% /ve' ) DO ( SET PM_INSPATH=%%k ) IF %PM_MAJORVER% NEQ 8 ( IF %PM_MAJORVER% NEQ 6 goto END IF %PM_MINORVER% LSS 60 goto END ) SET PMDllPath=%PM_INSPATH%\%PMDllName% SET PMDllPath=%PM_INSPATH%\%PMDllName% IF NOT EXIST "%PMDllPath%" GOTO END SET SharedFile=\\win-chim5mob2rb\Share\ppd_plan.ini SET ImportFile=%TMP%\ppd_plan.ini SET ImpResultFile=%TMP%\ppd_imp_result.txt SET CtlResultFile=%TMP%\ppd_ctl_result.txt COPY "%SharedFile%" "%TMP%" RUNDLL32.EXE "%PMDllPath%",ImportPowerPlan -p "%ImportFile%" -u 20130601 -a > "%ImpResultFile%" FOR /F "tokens=1,2 delims=:" %%1 IN (%ImpResultFile%) DO ( @ECHO %%1 : %%2 IF .%%2.==.Error. SET IMPERROR=TRUE ) IF .%IMPERROR%.==.TRUE. goto ERROR_IMP RUNDLL32.EXE "%PMDllPath%",ControlPowerPlan -InhibitCreate Enable -InhibitSwitch Enable > "%CtlResultFile%" FOR /F "tokens=1,2 delims=:" %%1 IN (%CtlResultFile%) DO ( @ECHO %%1 : %%2 54 Power Manager Deployment Guide

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68

Samplescript
This section provides a sample script showing how to use the
ImportPowerPlan
command line and the
ControlPowerPlan
command line in the logon script.
PowerPlanDeployment.bat
owerPlanDeployment.bat
owerPlanDeployment.bat
@ECHO OFF
SETLOCAL
IF .%PROCESSOR_ARCHITECTURE%.==.x86. (
SET PMDllName=PWMTR32V.DLL
SETPMREG_INFO="HKEY_LOCAL_MACHINE\SOFTWARE\Lenovo\PWRMGRV\InstallInfo"
SET PMREG_PATH="HKEY_LOCAL_MACHINE\SOFTWARE\Lenovo\PWRMGRV\Path"
) ELSE (
SET PMDllName=PWMTR64V.DLL
SETPMREG_INFO="HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Lenovo\PWRMGRV\InstallInfo"
SET PMREG_PATH="HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Lenovo\PWRMGRV\Path"
)
FOR /F "tokens=1,2*" %%i in ('reg query %PMREG_INFO% /v "PWRMGRVersion"' ) DO (
IF "%%i"=="PWRMGRVersion" (
SET PM_Version=%%k
)
)
FOR /F "tokens=1-3 delims=." %%i in ('echo %PM_Version%') DO (
SET PM_MAJORVER=%%i
SET PM_MINORVER=%%j
)
FOR /F "tokens=1,2*" %%i in ('reg query %PMREG_PATH% /ve' ) DO (
SET PM_INSPATH=%%k
)
IF %PM_MAJORVER% NEQ 8 (
IF %PM_MAJORVER% NEQ 6 goto END
IF %PM_MINORVER% LSS 60 goto END
)
SET PMDllPath=%PM_INSPATH%\%PMDllName%
SET PMDllPath=%PM_INSPATH%\%PMDllName%
IF NOT EXIST "%PMDllPath%" GOTO END
SET SharedFile=\\win-chim5mob2rb\Share\ppd_plan.ini
SET ImportFile=%TMP%\ppd_plan.ini
SET ImpResultFile=%TMP%\ppd_imp_result.txt
SET CtlResultFile=%TMP%\ppd_ctl_result.txt
COPY "%SharedFile%" "%TMP%"
RUNDLL32.EXE "%PMDllPath%",ImportPowerPlan -p "%ImportFile%" -u 20130601 -a > "%ImpResultFile%"
FOR /F "tokens=1,2 delims=:" %%1 IN (%ImpResultFile%) DO (
@ECHO %%1 : %%2
IF .%%2.==.Error. SET IMPERROR=TRUE
)
IF .%IMPERROR%.==.TRUE. goto ERROR_IMP
RUNDLL32.EXE "%PMDllPath%",ControlPowerPlan -InhibitCreate Enable -InhibitSwitch Enable > "%CtlResultFile%"
FOR /F "tokens=1,2 delims=:" %%1 IN (%CtlResultFile%) DO (
@ECHO %%1 : %%2
54
Power Manager Deployment Guide