10 Replies - 6246 Views - Last Post: 17 November 2011 - 11:24 AM Rate Topic: -----

#1 xialed  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 07-November 11

script will not work in windows 7

Posted 07 November 2011 - 06:05 PM

Hi everyone, I just started using a program (Ultra Hal)it allows users to write plug-ins using vb6.
unfortunately I'm not a coder, and there is a coder there that made a plug-in that works on xp, but not on vista or windows 7 that I really would like to use. the coder there does not have windows vista or windows 7 to test on. I was wondering if anyone can please help me get this code to work on windows 7 64 bit system. the codes placed below, and a link to the original source and discussion will be posted below the code. note: I'm not trying to steal someones code we have a community were people place there plug-ins for all Hal users to use or modify. if someone modifies someones code they mostly always give credit to original writer and previous modifiers. I really think having this plug-in work on windows 7 will help out not only me but the window 7 users with in the community. Any help with this will be greatly appreciated by me and others in the ultra Hal community.

'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
If InStr(1, InputString, "processor usage", 1) > 0 Or InStr(1, InputString, "processor time", 1) > 0 Or _ 
InStr(1, InputString, "cpu time", 1) > 0 Or InStr(1, InputString, "cpu usage", 1) > 0 Then
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
UltraHal = " Processor usage is " & objItem.PercentProcessorTime & "  %"
Next
End If

'THIS WILL GET AVAILABLE PHYSICAL MEMORY INFORMATION
If InStr(1, InputString, "physical memory", 1) > 0 Then
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\" & strComputer & "\rootcimv2")
Set colSettings = objWMIService.ExecQuery _
    ("Select * from Win32_OperatingSystem")
For Each objOperatingSystem In colSettings
UltraHal = " Available Physical Memory: " & _
        objOperatingSystem.FreePhysicalMemory & " MB "
Next
End If

'THIS WILL GET TOTAL PHYSICAL MEMORY INFORMATION
If InStr(1, InputString, "physical memory", 1) > 0 Then
Set colSettings = objWMIService.ExecQuery _
    ("Select * from Win32_ComputerSystem")
For Each objComputer In colSettings 
UltraHal = UltraHal & " Total Physical Memory: " & _
        objComputer.TotalPhysicalMemory & " MB "
Next
End If

'THIS WILL GET CPU CURRENT SPEED INFORMATION
If InStr(1, InputString, "processor usage", 1) > 0 Or InStr(1, InputString, "processor time", 1) > 0 Or _ 
InStr(1, InputString, "cpu time", 1) > 0 Or InStr(1, InputString, "cpu usage", 1) > 0 Or InStr(1, InputString, "clock speed", 1) > 0 Then
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
UltraHal = UltraHal & " Current Clock Speed: " & objItem.CurrentClockSpeed & " MHz"
Next
End If

'THIS WILL GET THE HARD DISK SPACE INFORMATION
If InStr(1, InputString, "hard disk space", 1) > 0 Or InStr(1, InputString, "harddisk space", 1) > 0 Or _
InStr(1, InputString, "free space", 1) > 0 Or InStr(1, InputString, "storage space", 1) > 0 Then
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) & "%)" & vbcrlf
End Select
Next 
Str = GetFreeSpaceReport
UltraHal = Str
End If

'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.
If InStr(1, InputString, "shut down computer", 1) > 0 Or InStr(1, InputString, "shut down system", 1) > 0 Then
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
End If



http://www.ultrahal....hp?topic=7004.0

Is This A Good Question/Topic? 0
  • +

Replies To: script will not work in windows 7

#2 maj3091  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 299
  • View blog
  • Posts: 1,768
  • Joined: 26-March 09

Re: script will not work in windows 7

Posted 08 November 2011 - 01:18 AM

Try changing the calls to the create the WMI using the following code, seemed to work on my Win7x64 (for the processor option that I tried):

Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" _
    & strComputer & "\root\cimv2")

Was This Post Helpful? 0
  • +
  • -

#3 xialed  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 07-November 11

Re: script will not work in windows 7

Posted 08 November 2011 - 12:37 PM

Thanks maj3091, for the reply
I believe I did what you suggested correctly but I still get errors. maybe I did it wrong? error info below code block.
within the plug-in code above in first post, I only changed the area that deals with the processor to the code in the code box below.

If InStr(1, InputString, "processor usage", 1) > 0 Or InStr(1, InputString, "processor time", 1) > 0 Or _
InStr(1, InputString, "cpu time", 1) > 0 Or InStr(1, InputString, "cpu usage", 1) > 0 Then
Set oWsh = CreateObject("WScript.Shell")
Set oWshSysEnv = oWsh.Environment("PROCESS")
GetCurrentComputerName = oWshSysEnv("COMPUTERNAME")
Set objWMIService = GetObject("winmgmts:" _
   & "{impersonationLevel=impersonate}!\\" _
   & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_PerfFormattedData_PerfOS_Processor WHERE Name = '_Total'")
For Each objItem In colItems
UltraHal = " Processor usage is " & objItem.PercentProcessorTime & "  %"
Next
End If



error message
HalScript Error -2147217375 on line 327 in column 0;

the file "C:\Program file (x86)\Zabaware\Ultra Hal Assistant
6\HalScript.DBG" has been saved with the current script being used for
debugging purposes


I looked at the DBG file counted down to line 327 and it reads
Set objWMIService = GetObject("winmgmts:\" & strComputer & '\rootCIMV2")
Was This Post Helpful? 0
  • +
  • -

#4 maj3091  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 299
  • View blog
  • Posts: 1,768
  • Joined: 26-March 09

Re: script will not work in windows 7

Posted 10 November 2011 - 07:31 AM

I never ran the full script, I just took the processor part and worked on that.

I believe you will need to make the same change in all the separate parts for it to work.
Was This Post Helpful? 0
  • +
  • -

#5 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 574
  • View blog
  • Posts: 2,989
  • Joined: 19-May 09

Re: script will not work in windows 7

Posted 10 November 2011 - 11:34 AM

Rather than doing all that to test it, you could also just pull out the processor part of your script and see if it works.
Was This Post Helpful? 0
  • +
  • -

#6 xialed  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 07-November 11

Re: script will not work in windows 7

Posted 10 November 2011 - 05:58 PM

Thanks for the help with this, it is really appreciated. I would of responded sooner but I been dealing with some personal issues the last 2 days.
I took out all the parts of the script except the processor and the hard drive part of the script, the two parts are listed below in the code block. Reason for leaving the hard drive part of the script is because it works. when I type in "hard disk space" I get hard drive info in the output panel. but when I type in "processor usage" I get the same error as in previous post.
I also removed the hard drive drive part of the code and still get the same error when I type in "processor usage" into the input panel.
I thought maybe this might be a Ultra Hal permission issue, So I right clicked the Ultra Hal.exe and chose run as administrator, but still get the same error even with Admin privileges. Note: I am also on the only user account set to administrator.

'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
If InStr(1, InputString, "processor usage", 1) > 0 Or InStr(1, InputString, "processor time", 1) > 0 Or _
InStr(1, InputString, "cpu time", 1) > 0 Or InStr(1, InputString, "cpu usage", 1) > 0 Then
Set oWsh = CreateObject("WScript.Shell")
Set oWshSysEnv = oWsh.Environment("PROCESS")
GetCurrentComputerName = oWshSysEnv("COMPUTERNAME")
Set objWMIService = GetObject("winmgmts:" _
   & "{impersonationLevel=impersonate}!\\" _
   & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_PerfFormattedData_PerfOS_Processor WHERE Name = '_Total'")
For Each objItem In colItems
UltraHal = " Processor usage is " & objItem.PercentProcessorTime & "  %"
Next
End If


'THIS WILL GET THE HARD DISK SPACE INFORMATION
If InStr(1, InputString, "hard disk space", 1) > 0 Or InStr(1, InputString, "harddisk space", 1) > 0 Or _
InStr(1, InputString, "free space", 1) > 0 Or InStr(1, InputString, "storage space", 1) > 0 Then
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) & "%)" & vbcrlf
End Select
Next 
Str = GetFreeSpaceReport
UltraHal = Str
End If

Was This Post Helpful? 0
  • +
  • -

#7 maj3091  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 299
  • View blog
  • Posts: 1,768
  • Joined: 26-March 09

Re: script will not work in windows 7

Posted 12 November 2011 - 03:27 AM

I can't comment on the UltraHal part, but the permissions on the PC maybe the thing.

Obviously I'm an admin on my own machine and with the processor script in a separate vbs file, it just worked for me.

Sorry I can't be more help.
Was This Post Helpful? 0
  • +
  • -

#8 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 574
  • View blog
  • Posts: 2,989
  • Joined: 19-May 09

Re: script will not work in windows 7

Posted 16 November 2011 - 01:24 PM

Can you tell what the text of HalScript error -2147217375 is?

Meanwhile, you might want to read this stuff on the winmgmts moniker to get a better idea of it. The problem appears to be with the settings you're sending with the moniker.
Was This Post Helpful? 0
  • +
  • -

#9 xialed  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 07-November 11

Re: script will not work in windows 7

Posted 17 November 2011 - 09:06 AM

maj3091,

Quote

I can't comment on the UltraHal part, but the permissions on the PC maybe the thing.

if it is the problem, I don't see how I can have give it any more permission. I am admin and only user, and Ultra Hal program is set to have full permission/control

Quote

Obviously I'm an admin on my own machine and with the processor script in a separate vbs file, it just worked for me.
I have tried to do this, but being a newbie I have not gotten to far. I created a vbs file and tried this code in it, and it does not work. I have lots to learn I guess.
Set oWsh = CreateObject("WScript.Shell")
Set oWshSysEnv = oWsh.Environment("PROCESS")

Set objWMIService = GetObject("winmgmts:" _
   & "{impersonationLevel=impersonate}!\\" _
   & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_PerfFormattedData_PerfOS_Processor WHERE Name = '_Total'")
For Each objItem In colItems
UltraHal = "Processor usage is " & objItem.PercentProcessorTime & "  %"

MsgBox = UltraHal 

Quote

Sorry I can't be more help.
No need for apologies, I thank you very much for all your time and help, it is greatly appreciated.

BobRodes,

Quote

Can you tell what the text of HalScript error -2147217375 is?

Set objWMIService = GetObject("winmgmts:\" & strComputer & '\rootCIMV2")
is what I believe your asking for, if not please let me know.

Thanks for the link, there is some great info there. I admit I did not understand some parts,like how they have exactly converted the two lines of code into 1 line. The 2 lines of code is pretty clear to me, but the merged 1 I don't quite get yet. but hopefully once I learn a bit more it will be more clear.
Was This Post Helpful? 0
  • +
  • -

#10 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 574
  • View blog
  • Posts: 2,989
  • Joined: 19-May 09

Re: script will not work in windows 7

Posted 17 November 2011 - 10:56 AM

No, it isn't what I'm asking for, sorry. I want to know WHAT THE ERROR IS. For example "Invalid Server Name" or some such. Do you have that?
Was This Post Helpful? 0
  • +
  • -

#11 xialed  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 07-November 11

Re: script will not work in windows 7

Posted 17 November 2011 - 11:24 AM

Thanks BobRodes, Sorry no I don't have the type of error. I did however post on the Zabawares forum for more info on this error. hopefully someone there can shed some light on the type of error this is. as soon as I get a answer I will let you know.

sorry if this double posts but my first post seemed like it did not to post.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1