Copying Files using WMI Query - file name is in lower case

Author Message
George_Levis

  • Total Posts : 2
  • Scores: 0
  • Reward points : 0
  • Joined: 11/29/2011
  • Status: offline
Copying Files using WMI Query - file name is in lower case Tuesday, November 29, 2011 7:18 PM (permalink)
0
Hi,
I am using CIM_DataFile class to copy files from one directory to another directory in remote machine. The file is get copied, but the destination file name is in lowercase.  For example, when i copy the file C:\Test.vbs to C:\Test1 directory, the resultant file name is test.vbs. But i need the exact filename what i given in the source.
 
I am pasting the part of code which i used in my script.
 


Set colFiles = wbemServices.ExecQuery("Select * from CIM_DataFile where Name = 'C:\Test.vbs'")
Dim destFolder : destFolder = "C:\Test1"
For Each fileItem in colFiles
Dim fName : fName = fileItem.FileName
If fileItem.Extension <> "" Then
fName = fName & "." & fileItem.Extension
End If
strNewFile = destFolder & "\" & fName
fileItem.CopyEx(strNewFile, failedObj, , true)
End If

 
 
Any help will be appreciated.
 
- George
 
 
 
 
 
 
#1
    59cobalt

    • Total Posts : 969
    • Scores: 91
    • Reward points : 0
    • Joined: 7/17/2011
    • Status: offline
    Re:Copying Files using WMI Query - file name is in lower case Wednesday, November 30, 2011 7:37 AM (permalink)
    0
    The Name property will always be lowercase. The FileName property, however, will return the name as it is in the filesystem. If fileItem.FileName returns "test", then the actual filename of the source file does not start with a capital "T".
     
    #2
      George_Levis

      • Total Posts : 2
      • Scores: 0
      • Reward points : 0
      • Joined: 11/29/2011
      • Status: offline
      Re:Copying Files using WMI Query - file name is in lower case Friday, December 02, 2011 2:16 AM (permalink)
      0
      Hi 59cobalt,
      Thanks for your help. What you said is correct, but for me is not working in all machines. I tested this in my network, in which all are 64 bit Windows 7 OS. In some machines it retrieved the exact filesystem name and in some machines file name is in lowercase even the file name starts with the capital "T".
      Is any wmi configuration is required to work on this ? Please help me.
       
      - George
       
       
       
       
       
       
       
      #3
        59cobalt

        • Total Posts : 969
        • Scores: 91
        • Reward points : 0
        • Joined: 7/17/2011
        • Status: offline
        Re:Copying Files using WMI Query - file name is in lower case Friday, December 02, 2011 9:18 AM (permalink)
        0
        I don't think there is anything configurable about this. I also can't see a reason why the property would lowercase a filename in one case, but not in another, so I'd double-check if those filenames really start with a capital "T". If they do, you'll probably have to drop WMI and resort to using the FileSystemObject methods.

        Why is preserving the case so important to you anyway? File access is not case-sensitive in Windows, so it doesn't matter at all whether the filename starts with an uppercase or a lowercase letter.
         
        #4

          Online Bookmarks Sharing: Share/Bookmark

          Jump to:

          Current active users

          There are 0 members and 1 guests.

          Icon Legend and Permission

          • New Messages
          • No New Messages
          • Hot Topic w/ New Messages
          • Hot Topic w/o New Messages
          • Locked w/ New Messages
          • Locked w/o New Messages
          • Read Message
          • Post New Thread
          • Reply to message
          • Post New Poll
          • Submit Vote
          • Post reward post
          • Delete my own posts
          • Delete my own threads
          • Rate post

          2000-2012 ASPPlayground.NET Forum Version 3.9