Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Create folder with version number
#1
Hello,

I am wondering if a tool inside QM could help me do this - or maybe a CMD command, although I haven't found how yet.

I am trying to create a folder on the disk, named with the version number of a software (this is a variable that changes over time, I don't want to hardcode it).
That version is in Help - About. It's also on a text file on my disk. It can also be found by right-clicking the file - Properties - details - product version.
It is NOT in the registry. I cannot see it with the "Explore windows" option of QM either (I thought maybe by checking the Help - About window..).

Thanks
#2
this function should work for you.

Function GetFileVersionString
Code:
Copy      Help
/
function# $file str&string [$infokind]

;Extracts string from version resource of exe or dll.
;infokind can be one of following strings (default is "FileDescription"):
;Comments InternalName ProductName CompanyName LegalCopyright ProductVersion FileDescription LegalTrademarks PrivateBuild FileVersion OriginalFilename SpecialBuild
;Returns 1 on success, 0 on failure.

;EXAMPLE
;str s
;if(GetFileVersionString("iexplore.exe" &s)) out s


;dll# version GetFileVersionInfoSize $lptstrFilename *lpdwHandle
;dll# version GetFileVersionInfo $lptstrFilename dwHandle dwLen !*lpData
;dll# version VerQueryValue !*pBlock $lpSubBlock !**lplpBuffer *puLen

if(!infokind or !infokind[0]) infokind="FileDescription"

str file2.searchpath(file); if(!file2.len) end "file not found"
int i vis=GetFileVersionInfoSize(file2, &i); if(!vis) ret
str s.all(vis 2) ss; word* lc; lpstr ls
if(!GetFileVersionInfo(file2, i, vis, s)) ret
if(!VerQueryValue(s, "\VarFileInfo\Translation", &lc, &i) or !lc or !i) ret

ss.format("\StringFileInfo\%04x%04x\%s" lc[0] lc[1] infokind)
if(VerQueryValue(s, ss, &ls, &i)) goto return
;lc[0] has problems with some programs (Word, Excel)
ss.format("\StringFileInfo\0409%04x\%s" lc[1] infokind)
if(VerQueryValue(s, ss, &ls, &i)) goto return
ret
;return
string=ls
ret 1


example 
Code:
Copy      Help
str filePath="$program files$\Windows Media Player\wmplayer.exe"
str s
if(GetFileVersionString(filePath &s "ProductVersion")) out s
;create folder with Product version as name
mkdir F"$Drive$\{s}"

or you can
Download file Archive.qml: Collected QM apps, functions, samples
Import folder FileVersionInfo from it. It is in folder Functions, classes..
examples inside folder
#3
Hello Kevin,

Thanks for taking the time to answer. I actually found an answer but it was using batch files. I prefer your method of doing it through QM. I will give it a go today.

What I ended up with was this command:
Code:
Copy      Help
@echo off
set "npver="&for /F "tokens=2delims==" %%a in ('wmic datafile where "Name='c:\\Windows\\System32\\notepad.exe'" get version /format:list') do set "npver=%%a"
echo mkdir c:\%npver%_20%date:~6,2%%date:~0,2%%date:~3,2% > c:\Commands\NPver.cmd

So it creates a cmd file that contains the Mkdir command, madeof the result of the version query, followed by today's date. I then called those CMD files via QM.
#4
Hello KeVin,
The version returned after executing the following code only shows a single number, 3, but in the actual properties window, it displays 3.10.10150.0.
thank you.

Code:
Copy      Help
if(GetFileVersionString("C:\Users\Administrator\Desktop\python-3.10.10-amd64.exe" &s "ProductVersion")) out s
https://i.ibb.co/7K5srVr/A.jpg
#5
Download and import this qml file it will work well for what you need. Examples inside


Attached Files
.qml   FileVersionInfo.qml (Size: 6 KB / Downloads: 32)
#6
Very helpful, thanks again.


Forum Jump:


Users browsing this thread: 1 Guest(s)