user29417931
user29417931

Reputation: 1

WMI queries to the CIM_DataFile class and the case of file name?

The problem: My test VBScript (Windows Platform) to obtain filenames return the name of file, all in lowercases!

I would like keep the real cases of the filenames. Anyone cant help me?

The WMI script:

requete = "Select * from CIM_DataFile Where Drive = 'M:' and Path ='\\Cabinet\\Test\\'"
set colFiles = objWMIService.ExecQuery (requete)
For Each objFile in colFiles
    Wscript.Echo objFile.FileName& "." & objFile.Extension
Next

After the latest comment I'm following... to specify.

I didn't talk about an environment variable problem.

Here you are the file list under my path :
2024-12-03_EMC Avis de prélèvement 2025.pdf
2024-12-03_ONPP Appel à Cotisations 2025.pdf
2025-01-01_Loyer Peyrollerie Janvier.pdf

Here you are with the WMI Script (bellow) :
2024-12-03_emc avis de prélèvement 2025
2024-12-03_onpp appel à cotisations 2025
2025-01-01_loyer peyrollerie janvier

The case is lost and I want the right case. That's the problem and I don't know why. Moreover with the WMI I can make request with, for example : "and FileName like '%IRCANTEC%'"" but not with FSO object. Is it more clear ?

Here you are with FSO :

Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oFolder = oFSO.GetFolder("M:\Cabinet\Test\")
For Each oFile In oFolder.Files
    WScript.Echo oFile.Name
    nomFichier = oFile.Name
Next

2024-12-03_EMC Avis de prélèvement 2025.pdf
2024-12-03_ONPP Appel à Cotisations 2025.pdf
2025-01-01_Loyer Peyrollerie Janvier.pdf
!!!!

Thanks a lot !

Upvotes: 0

Views: 41

Answers (0)

Related Questions