Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

This common Vbscript returns directory names which are all lowercase regardless of what case they are actually in.

$
0
0

Hi all,

This stock standard MS script below returns the first level directory listing. However, it does not return it the way it is in the actual directory. It alters the case which I desperately want to preserve, as I use this basic engine to get subdirectories to recreate the folders elsewhere.  E.g.

Source Directory:   C:\Windows\Web

Script output:  C:\windows\web

Does anyone know of a switch to stop it, or reason why it does not preserve the actual case of the original directory.

Geoff.

Code:-------------------------------------------------------------------------------------

Option Explicit

DIM strComputer,objWMIService,colSubfolders,objFolder

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
 & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colSubfolders = objWMIService.ExecQuery _
 ("ASSOCIATORS OF {Win32_Directory.Name='c:\windows'} " _
 & "WHERE AssocClass = Win32_Subdirectory " _
 & "ResultRole = PartComponent")
For Each objFolder in colSubfolders
 Wscript.Echo objFolder.Name
Next

------------------------------------------------------------------------------------------

Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>