Posts: 22
Threads: 10
Joined: Nov 2014
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
Posts: 1,333
Threads: 61
Joined: Jul 2006
this function should work for you.
Function
GetFileVersionString
/
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
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
Posts: 22
Threads: 10
Joined: Nov 2014
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:
@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.