Hollo everyone. I have pasted a two part script. I'm new to this so I don't
know how to prevent the first part from echoing the chassis type. What I
need for this script to do is check the chassis type and if the chassis type
is a laptop(8,9,10) the script should run the second part of the script. The
second part of the script changes the power scheme for the current user.
Please help. This seems like it should be easy for for someone with a
scripting background. I unfortunately don't know how to script. Thank you
in advance.
WScript.Echo GetFormFactor
Function GetFormFactor
Const adTypeBinary = 1
Dim objColl, o, obj, sResult, f, fso
Set fso = CreateObject("Scripting.FileSystemObject")
GetFormFactor = "D"
Set objColl = GetObject("winmgmts:").ExecQuery("SELECT * FROM
Win32_SystemEnclosure")
For each obj in objColl
For each o in obj.ChassisTypes
If (o = 8) or (o = 9) or (o = 10) Then : GetFormFactor = "L"
Next
Next
End Function
Dim intSleepTime
intSleepTime = 5000
Set WshShell = WScript.CreateObject("WScript.Shell")
' Set the Default to be "Custom Profile"
' Turn off Hibernation
WshShell.Run "%COMSPEC% /c POWERCFG /SETACTIVE ""Custom Profile"""
WshShell.Run "%COMSPEC% /c POWERCFG /Hibernate off"
' Start changing Power Management profiles' settings
' Change "Home/Office Desk" profile settings
WshShell.Run "%COMSPEC% /c POWERCFG /CHANGE ""Home/Office Desk""
/monitor-timeout-ac 5 /monitor-timeout-dc 5 /disk-timeout-ac 10
/disk-timeout-dc 10 /standby-timeout-ac 30 /standby-timeout-dc 30
/hibernate-timeout-ac 0 /hibernate-timeout-dc 0"
WScript.Sleep intSleepTime
' Change "Portable/Laptop" profile settings
WshShell.Run "%COMSPEC% /c POWERCFG /CHANGE ""Portable/Laptop""
/monitor-timeout-ac 5 /monitor-timeout-dc 5 /disk-timeout-ac 10
/disk-timeout-dc 10 /standby-timeout-ac 30 /standby-timeout-dc 30
/hibernate-timeout-ac 0 /hibernate-timeout-dc 20 /processor-throttle-ac
adaptive /processor-throttle-dc adaptive"
WScript.Sleep intSleepTime
' Cleanup
Set WshShell = Nothing
WScript.Quit(0)