1

I am trying to get the version number from an .exe using a Shell command in one of my VB6 projects.

the code goes like this:

BoVersion = Shell("wmic datafile where name='& boPath & ' get version")

    BoVersionArr() = Split(BoVersion, ".")
    
        boVerYear = CStr(BoVersionArr(0))
        boVerMonth = CStr(BoVersionArr(1))
        boVerDay = CStr(BoVersionArr(2))
        boVerMin = CStr(BoVersionArr(3))

when I run the command from CMD I get

enter image description here

but in the VB6 project, I try to assign this into a variable and I get the following, enter image description here

Does anyone know if I can convert this into a string or how to approach this? I am trying to split this and convert it into a date format which I have working.

Jean Camargo
  • 340
  • 3
  • 17
  • 2
    I used to do this by redirecting the output from the shell command to a text file using "> filename", checking if the file exists in vb, then reading the value from the text file. – John Eason Nov 15 '21 at 12:22
  • Here's a [similar question](https://stackoverflow.com/questions/2784367/capture-output-value-from-a-shell-command-in-vba/32600510) to get you started. Or [here](https://stackoverflow.com/questions/37841250/return-value-from-vba-call-shellwhatever-cmd). – Brian M Stafford Nov 15 '21 at 13:00
  • If you just want a file's version number simply use the `GetFileVersion()` method available [via FSO](https://devblogs.microsoft.com/scripting/how-can-i-determine-the-version-number-of-a-file/). If not WMI is COM based, you can call it directly. – Alex K. Nov 15 '21 at 14:31
  • 3
    Here's what VB6's help states about `Shell()`: "Runs an executable program and returns a Variant (Double) representing **the program's task ID** if successful, otherwise it returns zero." _(Emphasize mine)_, i.e. `Shell()` doesn't return what you hope it returns (the actual program's output). – Hel O'Ween Nov 15 '21 at 16:23

0 Answers0