B4J Question jUUID lib: error "java.io.IOException: Cannot run program "wmic" under Win11

peacemaker

Expert
Licensed User
Longtime User
Hi, All and @behnam_tr

Today a user of my app reported the error:

B4X:
java.io.IOException: Cannot run program "wmic": CreateProcess error=2, The system cannot find the file specified
    at java.base/java.lang.ProcessBuilder.start(Unknown Source)
    at java.base/java.lang.ProcessBuilder.start(Unknown Source)
    at java.base/java.lang.Runtime.exec(Unknown Source)
    at java.base/java.lang.Runtime.exec(Unknown Source)
    at java.base/java.lang.Runtime.exec(Unknown Source)
    at b4j/ir.padina.jUUID.Get_MachineID(Unknown Source)
    at b4j/peacemaker.app.others._get_deviceid(Unknown Source)
    at b4j/peacemaker.app.main._appstart(Unknown Source)
    at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(Unknown Source)
    at java.base/java.lang.reflect.Method.invoke(Unknown Source)
    at b4j/anywheresoftware.b4a.BA.raiseEvent2(Unknown Source)
    at b4j/anywheresoftware.b4a.BA.raiseEvent(Unknown Source)
    at b4j/peacemaker.app.main.start(Unknown Source)
    at javafx.graphics@19.0.2.1/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(Unknown Source)
    at javafx.graphics@19.0.2.1/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(Unknown Source)
    at javafx.graphics@19.0.2.1/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(Unknown Source)
    at java.base/java.security.AccessController.doPrivileged(Unknown Source)
    at javafx.graphics@19.0.2.1/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(Unknown Source)
    at javafx.graphics@19.0.2.1/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(Unknown Source)
    at javafx.graphics@19.0.2.1/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at javafx.graphics@19.0.2.1/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(Unknown Source)
    at java.base/java.lang.Thread.run(Unknown Source)
Caused by: java.io.IOException: CreateProcess error=2, Не удается найти указанный файл
    at java.base/java.lang.ProcessImpl.create(Native Method)
    at java.base/java.lang.ProcessImpl.<init>(Unknown Source)
    at java.base/java.lang.ProcessImpl.start(Unknown Source)
    ... 22 more
java.lang.StringIndexOutOfBoundsException: Range [0, 16) out of bounds for length 0
    at java.base/jdk.internal.util.Preconditions$1.apply(Unknown Source)
    at java.base/jdk.internal.util.Preconditions$1.apply(Unknown Source)
    at java.base/jdk.internal.util.Preconditions$4.apply(Unknown Source)
    at java.base/jdk.internal.util.Preconditions$4.apply(Unknown Source)
    at java.base/jdk.internal.util.Preconditions.outOfBounds(Unknown Source)
    at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckFromToIndex(Unknown Source)
    at java.base/jdk.internal.util.Preconditions.checkFromToIndex(Unknown Source)
    at java.base/java.lang.String.checkBoundsBeginEnd(Unknown Source)
    at java.base/java.lang.String.substring(Unknown Source)
    at b4j/ir.padina.jUUID.Get_HddID2(Unknown Source)
    at b4j/peacemaker.app.others._get_deviceid(Unknown Source)
    at b4j/peacemaker.app.main._appstart(Unknown Source)
    at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(Unknown Source)
    at java.base/java.lang.reflect.Method.invoke(Unknown Source)
    at b4j/anywheresoftware.b4a.BA.raiseEvent2(Unknown Source)
    at b4j/anywheresoftware.b4a.BA.raiseEvent(Unknown Source)
    at b4j/peacemaker.app.main.start(Unknown Source)
    at javafx.graphics@19.0.2.1/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(Unknown Source)
    at javafx.graphics@19.0.2.1/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(Unknown Source)
    at javafx.graphics@19.0.2.1/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(Unknown Source)
    at java.base/java.security.AccessController.doPrivileged(Unknown Source)
    at javafx.graphics@19.0.2.1/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(Unknown Source)
    at javafx.graphics@19.0.2.1/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(Unknown Source)
    at javafx.graphics@19.0.2.1/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at javafx.graphics@19.0.2.1/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(Unknown Source)
    at java.base/java.lang.Thread.run(Unknown Source)
others._get_deviceid (java line: -1)
java.lang.IndexOutOfBoundsException: Index 2 out of bounds for length 0
    at java.base/jdk.internal.util.Preconditions.outOfBounds(Unknown Source)
    at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Unknown Source)
    at java.base/jdk.internal.util.Preconditions.checkIndex(Unknown Source)
    at java.base/java.util.Objects.checkIndex(Unknown Source)
    at java.base/java.util.ArrayList.get(Unknown Source)
    at b4j/ir.padina.jUUID.Get_BiosVersion(Unknown Source)
    at b4j/peacemaker.app.others._get_deviceid(Unknown Source)
    at b4j/peacemaker.app.main._appstart(Unknown Source)
    at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(Unknown Source)
    at java.base/java.lang.reflect.Method.invoke(Unknown Source)
    at b4j/anywheresoftware.b4a.BA.raiseEvent2(Unknown Source)
    at b4j/anywheresoftware.b4a.BA.raiseEvent(Unknown Source)
    at b4j/peacemaker.app.main.start(Unknown Source)
    at javafx.graphics@19.0.2.1/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(Unknown Source)
    at javafx.graphics@19.0.2.1/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(Unknown Source)
    at javafx.graphics@19.0.2.1/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(Unknown Source)
    at java.base/java.security.AccessController.doPrivileged(Unknown Source)
    at javafx.graphics@19.0.2.1/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(Unknown Source)
    at javafx.graphics@19.0.2.1/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(Unknown Source)
    at javafx.graphics@19.0.2.1/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at javafx.graphics@19.0.2.1/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(Unknown Source)
    at java.base/java.lang.Thread.run(Unknown Source)

in the getting win hardware ID sub https://www.b4x.com/android/forum/t...ets-test-windows-os-hardware-device_id.165018 under Windows11 24H2.

The WMI command-line (WMIC) utility provides a command-line interface for Windows Management Instrumentation (WMI).

@behnam_tr, is it possible to debug the lib v.2.7 under this Win version for you ?

@Peter Simpson, did your customers use the jUUID lib in your apps under Win11 already?
 
Last edited:

Daestrum

Expert
Licensed User
Longtime User
when I ran your test (the other thread mentioned) I was using 24H2
 
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
1736694464742.png


I do get a warning though if I use from command prompt

>wmic /?

WMIC is deprecated.

[global switches] <command>

The following global switches are available:
/NAMESPACE Path for the namespace the alias operate against.
/ROLE Path for the role containing the alias definitions.
/NODE Servers the alias will operate against.
/IMPLEVEL Client impersonation level.
 
Upvote 0

behnam_tr

Active Member
Licensed User
Longtime User
ooops, interesting...

So, seems the jUUID lib depends on the system "wmic" utility that ... may be absent.
check this :
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
check this
MS is super...
Please, make in the lib try\catch on each function, to make sure that "null" is returned also if WMIC trouble would be on the user machine.
Or more correct is to trap on the app side ?
 
Upvote 0

behnam_tr

Active Member
Licensed User
Longtime User
MS is super...
Please, make in the lib try\catch on each function, to make sure that "null" is returned also if WMIC trouble would be on the user machine.
Or more correct is to trap on the app side ?
I tested it on version 24 and the problem was solved by enabling Wmic.
Yes, I will update soon and add a try/catch.
And also the ability to check wmic feature is enable or not.
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
I already added try\catch so:

B4X:
Sub Get_DeviceID As String
    Dim sb As StringBuilder
    sb.Initialize
    Dim sr As String
    Try   
        Dim sr As String = pdd.Get_MotherboardSN
        If sr <> Null And Not(sr.Contains("O.E.M")) Then sb.Append(sr)
    Catch
    End Try
    Try
        sr = pdd.Get_CPUID
        If sr <> Null Then sb.Append(sr)
    Catch
    End Try
    Try
        sr = pdd.Get_MachineID
        If sr <> Null Then sb.Append(sr)
    Catch
    End Try
    Try
        sr = pdd.Get_HddID1
        If sr <> Null Then sb.Append(sr)
    Catch
    End Try
    Try
        sr = pdd.Get_HddID2
        If sr <> Null Then sb.Append(sr)
    Catch
    End Try
    Try
        sr = pdd.Get_MacId
        If sr <> Null Then sb.Append(sr)
    Catch
    End Try
    Try
        sr = pdd.Get_BiosVersion
        If sr <> Null Then sb.Append(sr)
    Catch
    End Try
    Try
        sr = pdd.Get_CPUName
        If sr <> Null Then sb.Append(sr)
    Catch
    End Try
    Try
        sr = pdd.Get_GpuID
        If sr <> Null Then sb.Append(sr)
    Catch
    End Try
    Try
        sr = pdd.Get_MotherboardSN2
        If sr <> Null Then sb.Append(sr)
    Catch
    End Try
    Try
        sr = pdd.Get_HWID1
        If sr <> Null Then sb.Append(sr)
    Catch
    End Try
    
    sr = sb.ToString
    
    If sr.Trim.Length < 8 Then
        sr = sr & GetEnvironmentVariable("computername","") & GetSystemProperty("user.name","")
    End If
    sr = sr.Replace(" ", "").Replace("\", "").Replace("/", "").Replace(":", "")
    sr = Main.appname & "_" & sr
    If sr.Length > 48 Then
        sr = sr.SubString2(0, 48)
    End If
    
    Return sr.ToLowerCase
End Sub

App on those user machine (with initial error) was started OK and returned "defaultstringbfebfbff000806c1104595......".
Some "defaultstring" 😜
 
Upvote 0

behnam_tr

Active Member
Licensed User
Longtime User
I already added try\catch so:

B4X:
Sub Get_DeviceID As String
    Dim sb As StringBuilder
    sb.Initialize
    Dim sr As String
    Try  
        Dim sr As String = pdd.Get_MotherboardSN
        If sr <> Null And Not(sr.Contains("O.E.M")) Then sb.Append(sr)
    Catch
    End Try
    Try
        sr = pdd.Get_CPUID
        If sr <> Null Then sb.Append(sr)
    Catch
    End Try
    Try
        sr = pdd.Get_MachineID
        If sr <> Null Then sb.Append(sr)
    Catch
    End Try
    Try
        sr = pdd.Get_HddID1
        If sr <> Null Then sb.Append(sr)
    Catch
    End Try
    Try
        sr = pdd.Get_HddID2
        If sr <> Null Then sb.Append(sr)
    Catch
    End Try
    Try
        sr = pdd.Get_MacId
        If sr <> Null Then sb.Append(sr)
    Catch
    End Try
    Try
        sr = pdd.Get_BiosVersion
        If sr <> Null Then sb.Append(sr)
    Catch
    End Try
    Try
        sr = pdd.Get_CPUName
        If sr <> Null Then sb.Append(sr)
    Catch
    End Try
    Try
        sr = pdd.Get_GpuID
        If sr <> Null Then sb.Append(sr)
    Catch
    End Try
    Try
        sr = pdd.Get_MotherboardSN2
        If sr <> Null Then sb.Append(sr)
    Catch
    End Try
    Try
        sr = pdd.Get_HWID1
        If sr <> Null Then sb.Append(sr)
    Catch
    End Try
   
    sr = sb.ToString
   
    If sr.Trim.Length < 8 Then
        sr = sr & GetEnvironmentVariable("computername","") & GetSystemProperty("user.name","")
    End If
    sr = sr.Replace(" ", "").Replace("\", "").Replace("/", "").Replace(":", "")
    sr = Main.appname & "_" & sr
    If sr.Length > 48 Then
        sr = sr.SubString2(0, 48)
    End If
   
    Return sr.ToLowerCase
End Sub

App on those user machine (with initial error) was started OK and returned "defaultstringbfebfbff000806c1104595......".
Some "defaultstring" 😜

Which method returns this value?
 
Upvote 0
Top