Author Topic: Hal pc control  (Read 16600 times)

sybershot

  • Hero Member
  • *****
  • Posts: 787
    • View Profile
Hal pc control
« Reply #15 on: March 15, 2010, 03:35:24 pm »
window 1:
SYBERSHOT-PC

window 2:
Script:   C:UsersSybershotDesktopTester.vbs
Line:   20
Char:   1
Error:   0x80041021
Code:   80041021
Source:   (null)

complete code of vbs
Set oWsh = CreateObject("WScript.Shell")
Set oWshSysEnv = oWsh.Environment("PROCESS")
GetCurrentComputerName = oWshSysEnv("COMPUTERNAME")
MsgBox GetCurrentComputerName

'Constants for drive types
Const Unknown = 0
Const Removable = 1
Const Fixed = 2
Const Remote = 3
Const CDROM = 4
Const RAMDisk = 5
Const strComputer = "."

'THIS WILL GET CPU USAGE INFORMATION

Set oWsh = CreateObject("WScript.Shell")
Set oWshSysEnv = oWsh.Environment("PROCESS")
GetCurrentComputerName = oWshSysEnv("COMPUTERNAME")
Set objWMIService = GetObject("winmgmts:\" & strComputer & "\rootCIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_PerfFormattedData_PerfOS_Processor WHERE Name = '_Total'")
For Each objItem In colItems
MsgBox " Processor usage is " & objItem.PercentProcessorTime & "  %"
Next


'THIS WILL GET AVAILABLE PHYSICAL MEMORY INFORMATION

Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\" & strComputer & "\rootcimv2")
Set colSettings = objWMIService.ExecQuery _
    ("Select * from Win32_OperatingSystem")
For Each objOperatingSystem In colSettings
MsgBox " Available Physical Memory: " & _
        objOperatingSystem.FreePhysicalMemory & " MB "
Next


'THIS WILL GET TOTAL PHYSICAL MEMORY INFORMATION

Set colSettings = objWMIService.ExecQuery _
    ("Select * from Win32_ComputerSystem")
For Each objComputer In colSettings
MsgBox " Total Physical Memory: " & _
        objComputer.TotalPhysicalMemory /10241024+1 & "MB"
Next


'THIS WILL GET CPU CURRENT SPEED INFORMATION

Set oWsh = CreateObject("WScript.Shell")
Set oWshSysEnv = oWsh.Environment("PROCESS")
GetCurrentComputerName = oWshSysEnv("COMPUTERNAME")
Set objWMIService = GetObject("winmgmts:\" & strComputer & "\rootCIMV2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Processor")
For Each objItem In colItems
MsgBox " Current Clock Speed: " & objItem.CurrentClockSpeed & " MHz"
Next


'THIS WILL GET THE HARD DISK SPACE INFORMATION

Set oFs = CreateObject("Scripting.FileSystemObject")
         Set oDrives = oFs.Drives
          For Each oDrive In oDrives
         Select Case oDrive.DriveType
      Case Fixed
GetFreeSpaceReport = GetFreeSpaceReport & oDrive.DriveLetter & ": " & Round(oDrive.FreeSpace/(1024*1024)) & "MB free (" & Round(100 * (oDrive.FreeSpace/oDrive.TotalSize),2) & "%)"
End Select
Next
MsgBox GetFreeSpaceReport



'THIS WILL ALLOW A USER TO SHUT DOWN THE COMPUTER
'THIS SCRIPT WILL WORK WELL WITH ASSISTANT BUT MAY CAUSE
'PROBLEMS WITH AIM BOT USERS BECAUSE ANYONE USING AIM
'COULD SHUT DOWN YOUR COMPUTER ON COMMAND.

'Set oWshX = CreateObject("WScript.Shell")
'Set oWshSysEnvX = oWshX.Environment("PROCESS")
'GetCurrentComputerName = oWshSysEnvX("COMPUTERNAME")
    'strShutdown = "shutdown -s -t 0 -f -m \" & GetCurrentComputerName
    'Set objShell = CreateObject("WScript.Shell")
    'objShell.Run strShutdown


onthecuttingedge2005

  • Guest
Hal pc control
« Reply #16 on: March 15, 2010, 08:08:47 pm »
Hi Sybershot.

could you try each code set individually, that way I can debug each set for you.

thanks
Jerry

sybershot

  • Hero Member
  • *****
  • Posts: 787
    • View Profile
Hal pc control
« Reply #17 on: March 15, 2010, 08:32:51 pm »
Code: [Select]
Set oWsh = CreateObject("WScript.Shell")
Set oWshSysEnv = oWsh.Environment("PROCESS")
GetCurrentComputerName = oWshSysEnv("COMPUTERNAME")
MsgBox GetCurrentComputerName

'Constants for drive types
Const Unknown = 0
Const Removable = 1
Const Fixed = 2
Const Remote = 3
Const CDROM = 4
Const RAMDisk = 5
Const strComputer = "."

'THIS WILL GET CPU USAGE INFORMATION

Set oWsh = CreateObject("WScript.Shell")
Set oWshSysEnv = oWsh.Environment("PROCESS")
GetCurrentComputerName = oWshSysEnv("COMPUTERNAME")
Set objWMIService = GetObject("winmgmts:\" & strComputer & "\rootCIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_PerfFormattedData_PerfOS_Processor WHERE Name = '_Total'")
For Each objItem In colItems
MsgBox " Processor usage is " & objItem.PercentProcessorTime & "  %"
Next

Script: C:UsersSybershotDesktopTester.vbs
Line: 20
Char: 1
Error: 0x80041021
Code: 80041021
Source: (null)

Code: [Select]
Set oWsh = CreateObject("WScript.Shell")
Set oWshSysEnv = oWsh.Environment("PROCESS")
GetCurrentComputerName = oWshSysEnv("COMPUTERNAME")
MsgBox GetCurrentComputerName

'Constants for drive types
Const Unknown = 0
Const Removable = 1
Const Fixed = 2
Const Remote = 3
Const CDROM = 4
Const RAMDisk = 5
Const strComputer = "."

'THIS WILL GET AVAILABLE PHYSICAL MEMORY INFORMATION

Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\" & strComputer & "\rootcimv2")
Set colSettings = objWMIService.ExecQuery _
    ("Select * from Win32_OperatingSystem")
For Each objOperatingSystem In colSettings
MsgBox " Available Physical Memory: " & _
        objOperatingSystem.FreePhysicalMemory & " MB "
Next
 
Script: C:UsersSybershotDesktopTester.vbs
Line: 17
Char: 1
Error: 0x80041021
Code: 80041021
Source: (null)

Code: [Select]
Set oWsh = CreateObject("WScript.Shell")
Set oWshSysEnv = oWsh.Environment("PROCESS")
GetCurrentComputerName = oWshSysEnv("COMPUTERNAME")
MsgBox GetCurrentComputerName

'Constants for drive types
Const Unknown = 0
Const Removable = 1
Const Fixed = 2
Const Remote = 3
Const CDROM = 4
Const RAMDisk = 5
Const strComputer = "."

'THIS WILL GET TOTAL PHYSICAL MEMORY INFORMATION

Set colSettings = objWMIService.ExecQuery _
    ("Select * from Win32_ComputerSystem")
For Each objComputer In colSettings
MsgBox " Total Physical Memory: " & _
        objComputer.TotalPhysicalMemory /10241024+1 & "MB"
Next
Script: C:UsersSybershotDesktopTester.vbs
Line: 17
Char: 1
Error: Object required:'objWMIService'
Code: 800A01A8
Source: Microsoft VBScript runtime error

Code: [Select]
Set oWsh = CreateObject("WScript.Shell")
Set oWshSysEnv = oWsh.Environment("PROCESS")
GetCurrentComputerName = oWshSysEnv("COMPUTERNAME")
MsgBox GetCurrentComputerName

'Constants for drive types
Const Unknown = 0
Const Removable = 1
Const Fixed = 2
Const Remote = 3
Const CDROM = 4
Const RAMDisk = 5
Const strComputer = "."

'THIS WILL GET CPU CURRENT SPEED INFORMATION

Set oWsh = CreateObject("WScript.Shell")
Set oWshSysEnv = oWsh.Environment("PROCESS")
GetCurrentComputerName = oWshSysEnv("COMPUTERNAME")
Set objWMIService = GetObject("winmgmts:\" & strComputer & "\rootCIMV2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Processor")
For Each objItem In colItems
MsgBox " Current Clock Speed: " & objItem.CurrentClockSpeed & " MHz"
Next
Script: C:UsersSybershotDesktopTester.vbs
Line: 20
Char: 1
Error: 0x80041021
Code: 80041021
Source: (null)

Code: [Select]
Set oWsh = CreateObject("WScript.Shell")
Set oWshSysEnv = oWsh.Environment("PROCESS")
GetCurrentComputerName = oWshSysEnv("COMPUTERNAME")
MsgBox GetCurrentComputerName

'Constants for drive types
Const Unknown = 0
Const Removable = 1
Const Fixed = 2
Const Remote = 3
Const CDROM = 4
Const RAMDisk = 5
Const strComputer = "."

'THIS WILL GET THE HARD DISK SPACE INFORMATION

Set oFs = CreateObject("Scripting.FileSystemObject")
         Set oDrives = oFs.Drives
          For Each oDrive In oDrives
         Select Case oDrive.DriveType
      Case Fixed
GetFreeSpaceReport = GetFreeSpaceReport & oDrive.DriveLetter & ": " & Round(oDrive.FreeSpace/(1024*1024)) & "MB free (" & Round(100 * (oDrive.FreeSpace/oDrive.TotalSize),2) & "%)"
End Select
Next
MsgBox GetFreeSpaceReport
C:176714MB free (59.85%)G:153425MB free(50.28%)

next one is shut down so I will post now so I don't loose info for testing and posting live


Code: [Select]
Set oWsh = CreateObject("WScript.Shell")
Set oWshSysEnv = oWsh.Environment("PROCESS")
GetCurrentComputerName = oWshSysEnv("COMPUTERNAME")
MsgBox GetCurrentComputerName

'Constants for drive types
Const Unknown = 0
Const Removable = 1
Const Fixed = 2
Const Remote = 3
Const CDROM = 4
Const RAMDisk = 5
Const strComputer = "."


'THIS WILL ALLOW A USER TO SHUT DOWN THE COMPUTER
'THIS SCRIPT WILL WORK WELL WITH ASSISTANT BUT MAY CAUSE
'PROBLEMS WITH AIM BOT USERS BECAUSE ANYONE USING AIM
'COULD SHUT DOWN YOUR COMPUTER ON COMMAND.

'Set oWshX = CreateObject("WScript.Shell")
'Set oWshSysEnvX = oWshX.Environment("PROCESS")
'GetCurrentComputerName = oWshSysEnvX("COMPUTERNAME")
    'strShutdown = "shutdown -s -t 0 -f -m \" & GetCurrentComputerName
    'Set objShell = CreateObject("WScript.Shell")
    'objShell.Run strShutdown
no system shut down. dough! just realized you commented out^^
un-commented last 6 lines, got a blank dos box to appear for 2 to 3 seconds
no system shut down

 
« Last Edit: March 15, 2010, 08:45:35 pm by sybershot »

onthecuttingedge2005

  • Guest
Hal pc control
« Reply #18 on: March 15, 2010, 08:40:13 pm »
Hi Sybershot.

can you go to run, regedit, look for HKEY_CLASSES_ROOT\WINMGMTS

does the hot key class exist in your computer's registry?
« Last Edit: March 15, 2010, 08:40:51 pm by onthecuttingedge2005 »

sybershot

  • Hero Member
  • *****
  • Posts: 787
    • View Profile
Hal pc control
« Reply #19 on: March 15, 2010, 09:25:23 pm »
I looked manually for HKEY_CLASSES_ROOTWINMGMTS and I have nothing starting with HKEY as a main folder, I did a search, and came up empty handed

sybershot

  • Hero Member
  • *****
  • Posts: 787
    • View Profile
Hal pc control
« Reply #20 on: March 15, 2010, 09:38:28 pm »
i did find this on a vista forum, if it helps.

"Note that HKEY_CLASSES_ROOT is HKEY_LOCAL_MACHINESoftwareClasses and
HKEY_CURRENT_USERSoftwareClasses combined together, with entries in
HKCU taking precedence.
I believe writes to this location get sent to HKLM, but not exactly sure."

I used the search function in registry just for HKEY main folders =
HKEY_CURRENT_USER
HKEY_LOCAL_MACHINE
HKEY_USER
HKEY_CYRRENT_CONFIG

EDIT: there is a HKEY_CLASSES_ROOT main folder, was at the top, still no ROOTWINMGMTS within. I was rushing to post to try and catch you and did not notice it.
« Last Edit: March 15, 2010, 10:01:49 pm by sybershot »

sybershot

  • Hero Member
  • *****
  • Posts: 787
    • View Profile
Hal pc control
« Reply #21 on: March 15, 2010, 10:49:43 pm »
if this helps I also searched for JUST "winmgmts"

HKEY-LOCAL-MACHINE
..SOFTWARE
....CLASSES
......CLSID
........172bDDF8-CEEA-11D1-8B05-00600806D9B6
..........InProcServer32
..........ProgID
..........VersionIndependentProgID

InProcServer32:
NAME......TYPE..............DATA
(Default).REG_EXPAND_SZ..%SystemRoot%system32wbemwbemdisp.dll  
ThreadingModel..REG_SZ...Apartment

ProgID:
NAME......TYPE...........DATA
(default).REG_SZ.........WINMGMTS.1

VersionIndependentProgID
NAME......TYPE...........DATA
(default).REG_SZ.........WINMGMTS

edit: had to add "...." for indentation
« Last Edit: March 15, 2010, 10:55:10 pm by sybershot »

onthecuttingedge2005

  • Guest
Hal pc control
« Reply #22 on: March 15, 2010, 11:03:40 pm »
You can download the WMI core from Microsoft here:

http://download.microsoft.com/download/platformsdk/wmint4/1.5/NT4/EN-US/wmint4.EXE

install it and see if writes to the registry: HKEY_CLASSES_ROOT\WINMGMTS

we can start here to see if this problem gets resolved.
I am not sure what the minimum and maximum O/S supported. if not support it may not install.

once installed, reboot your system to refresh your registry.

after reboot you can try to run the vbscript codes to see if you still get errors.

also when posting backslashes in the forum use two backslashes to post root directories properly, forward slashes are not effect by the filtering on this forum.
« Last Edit: March 15, 2010, 11:05:22 pm by onthecuttingedge2005 »

sybershot

  • Hero Member
  • *****
  • Posts: 787
    • View Profile
Hal pc control
« Reply #23 on: March 16, 2010, 09:16:31 am »
Unsupported Platform

This version of the WMI Core Components is
only supported on Windows NT 4.0 Service
Pack 4 or later Versions of Windows NT 4

sybershot

  • Hero Member
  • *****
  • Posts: 787
    • View Profile
Hal pc control
« Reply #24 on: March 16, 2010, 05:01:58 pm »
I have been Google searching for ketwords such as "vb, vista system info, etc" to try and find out why this does not work. I have had no luck yet.
Though I did find somewhere in the vista forums someone asking a similar question. I think it was system volume control using vb, a person responded by stating that even though your under a admin account, have user account control turned off, that in vista you have to run it as admin by right clicking the exe, vbs, etc. and click run as admin.
I did this with Hal and got the same error results.
I went to do this with the Tester.vbs and "run as admin" was not in the menu.
Is it suppose to be in the menu for a .vbs?
If it is suppose to be there, maybe it is a clue to why it is not working.



onthecuttingedge2005

  • Guest
Hal pc control
« Reply #25 on: March 16, 2010, 08:51:12 pm »
Hi Sybershot.

try turning off your UAC, UAC is the program that keeps some scripts and stuff from running as a security feature in windows vista and windows 7.

http://www.petri.co.il/disable_uac_in_windows_vista.htm

you can read this article and learn to turn it off or on, turning it off also keeps those nagging security screens from running that say, are you sure you want to run this program! a real pain in the butt to me.

this is strictly to see if the "shut down vbscript code" I gave you will work as it is supposed to if UAC is turned off.

sybershot

  • Hero Member
  • *****
  • Posts: 787
    • View Profile
Hal pc control
« Reply #26 on: March 18, 2010, 04:47:42 pm »
sorry I was not able to get back right away, I had quite a few problems yesterday, and was away from my computer.

My UAC has not been turned back on (except to test with it on) for some time now, at least 3 months.

with the UAC off or on I get a Dos box that opens up, and closes just as fast as it opened up, and nothing happens.