PDA

View Full Version : WMIc deprecated



ReneMiner
28-03-2020, 09:47
It's already like that (displayed if input "WMI" to commandline) WMI/WMIC is deprecated.

Anyway WMI module depends on it but since iDispatch is part of the core-module i would consider to drop the "experimental WMI-module" and its sample-file out of the shipped Installer-package.
Maintain it maybe as an optional additional module, available in forum somewhere together with some note that WMI.dll is required etc.


Also OnlineScores-module could be migrated as an optional additional download since it will not function without any preparation of the forum-software. That still can be done as soon as someone asks for it
And if someone reallly uses it, it will be no big deal to have thinbasic downloading the required module ´(It's ONLINE-scores so if anyone wants to use it he will be connected to the internet anyway...)
Just mention in Help where to obtain it ("additional modules in forum") and just start a slight cleanout of things that will be deprecated soon or that were never used by anyone.

DirectuX
28-03-2020, 11:52
about wmi there is some nuance :

As mentioned in comments, WMIC is utility that acts as interface to communication with WMI. It's not WMI itself that is being deprecated, but "just" the interface.
source: https://stackoverflow.com/questions/57121875/what-can-i-do-about-wmic-is-deprecated

Petr Schreiber
28-03-2020, 21:47
Hi Rene, DirectuX,

thanks for the information. I think it would be good to add information to help file, that WMI[C] might be in danger on Windows 10. I did not know it and I thank you for letting us know :drink:

However, as we have users of older Windows in thinBASIC users base, for these it is perfectly valid tool.

If we find feature which has no future (may be the case of WMI), I think we should:
- state it clearly in release notes/forum/social media
- state it clearly in help file
- remove it in next Major release (thinBasic 2.x)

I have features in TBGL marked as deprecated since 2006, but I will remove them completely not sooner than in ThinBASIC 2.x.

I would personally perform removal/breaking changes only in case:
- of major version number change (thinBasic 1.x -> 2.x)
- in Beta versions - Beta version are experimental, to get feedback on shaping of new features, and change is possible/expected, as nobody responsible uses Beta version on critical projects

This way users can update their thinBASIC 1.x stable on production with confidence their older code runs without any change.

I am sure there will be well justified exceptions from these rules, but not everyone has time to monitor release notes to find one of the 1000 changes contains something which will break his code.

What would be ideal for sure is some kind of tool to analyze scripts and warn you about usage of deprecated functions.


Petr

ReneMiner
09-07-2025, 06:55
quite a while ago...
Current Win11 24H2 has it- as some other no more functioning commands stil in CMD-help - but try type in WMiC ...:neutral:

Joe Caverly
09-07-2025, 15:36
Here's an example of thinBasic using WMI via PowerShell;

uses "Console"
' Uses "Trace"

dim ps as iDispatch
dim result as string

printl "Creating PSCom.PSScript object"

' Ref: https://www.thinbasic.com/community/showthread.php?13383-Execute-a-PowerShell-ps1-script-or-a-PowerShell-command(s)
ps = CreateObject("PSCom.PSScript")

if IsComObject(ps) then
printl "Get-CimInstance -Query 'Select * from Win32_BIOS'"
result = ps.ExecuteCommand("Get-CimInstance -Query 'Select * from Win32_BIOS'")

Printl result
Else
Printl "Could not create PSCom.PSScript object"
end if

ps = Nothing

Ref: https://www.thinbasic.com/community/showthread.php?13383-Execute-a-PowerShell-ps1-script-or-a-PowerShell-command(s)&p=96993&viewfull=1#post96993

One could also use C# to utilize WMI.
Ref: https://www.thinbasic.com/community/showthread.php?13387-A-simple-C-ActiveX-COM-dll&p=97002#post97002

Joe

ReneMiner
13-07-2025, 03:47
not a problem here, thinbasics only All-In-One-function-module "WMI" is still fine and WMI_GetData will -
if knowing the class and what we are looking for or we know what to pass for the "WHERE?"-parameter
to make it show some results at all - a bit as the Jeopardy-show that ran decades ago on tv-

- because in some cases it's required to fetch some object this way,
e.g. when looking for some information about files in some folders of different volumes
and the WMI-class we query has fields as
"Driveletter" showing like "C:" or "D:".
"Volume"="[local volume] C:"
"Path" shows values like "\Windows\System32",
"FullPath" -obvious- as "C:\Windows\System32\winload.efi",
"Filename" as "Winload.efi" "Notepad.exe" or "System.cpl"
"Directory" ="System32 " or ="Roaming",
"Extension"=".exe" or ".ms-calculator"
"Rootpath" ="\Windows", ="\Users" etc.
"Name" = "Regedit",or maybe "Paint"
and certainly more
- once we got the class to show up when the fields-paramter (the last one) was empty, it will list all fields
and when looking for the present values of these named fields it's easy to conclude what else can be asked
for and what will be the result -as mentioned before just like the Jeopardy-game -
the answer is the question that is to ask in order to receive the object what it is about

usually some fields as "Name" and "Caption" or "Description" have the same value,
"Name" (if available) is always present in the returned information, all collections and arrays have some index,
plenty of win32-classes have a "handle", programs come with a ProcessID, for example when we make a program to
run in a single instance only - the question is before we cancel the second instance by ending its process our script
would ask to list the processIDs except for the own id of the first running instance and the commandline that was used
to invoke the process since we want to open maybe the document that was clicked


string sClass= "Win32_Process"
string sWhere = StrFormat$("FullQualifiedPath={1}{2]{1} AND (NOT ProcessID={1}{3}{1})",
CHR$(ßx27),
Replace$( App_Sourcefullname,"\", With "\\"),
App. Proces.ID)

string sFields ="Commandline,ProcessID"


In sWhere: use single quotes to quote strings inside of a string, i did insert them here using CHR-function (matter of eyesight)
backslashes must be escaped with a backslash = \\
single quotes - to appear as such also need an escapement= \'
terminating CHR$(0) to test strings for "not ending yet" - not sure either= \0 or \z
also concetanation was possible somehow using & or +
assume you know a file starts where "Extension='.exe' AND (Name='thin' & NOT '\0' )" would catch "thinAir.exe" and "thinBasic.exe"
\z | \0 ? guess any of this was for a terminating CHR$(0)- as i remember it was to check whether a string ends or not
AND + NOT + OR + AND NOT (=exclude) can be used as logical operators
( ) parentheses='for precedence'