I have another WMI question. How do you use the WMI to copy a file from a remote server to a local PC? I have the following code, which does not generate any errors yet it does not copy the file either. Someone please help!!
Dim objWMI, objLocator, objWMIFiles, objWMIFile
Dim strUpdateDirectory As String
Dim strFrameworkPath As String
Dim strSQLServer As String
Dim strString As String
strSQLServer = "CPSPE17"
Set objLocator = CreateObject("WbemScripting.SWbemLocator")
Set objWMI = objLocator.ConnectServer(strSQLServer, "root/cimv2", username and password omitted)
objWMI.Security_.ImpersonationLevel = 3
Set objWMIFiles = objWMI.execquery("ASSOCIATORS OF {Win32_Directory.Name='E:\Framework\Test_JDS'} WHERE ResultClass = CIM_DataFile")
strString = "C:\Test_JDS\Test_JDS.txt"
For Each objWMIFile In objWMIFiles
If objWMIFile.FileName = LCase("Test_JDS") Then
objWMIFile.Copy strString
End If
Next
Set objWMI = Nothing
Set objWMIFile = Nothing
Set objWMIFiles = Nothing
Dim objWMI, objLocator, objWMIFiles, objWMIFile
Dim strUpdateDirectory As String
Dim strFrameworkPath As String
Dim strSQLServer As String
Dim strString As String
strSQLServer = "CPSPE17"
Set objLocator = CreateObject("WbemScripting.SWbemLocator")
Set objWMI = objLocator.ConnectServer(strSQLServer, "root/cimv2", username and password omitted)
objWMI.Security_.ImpersonationLevel = 3
Set objWMIFiles = objWMI.execquery("ASSOCIATORS OF {Win32_Directory.Name='E:\Framework\Test_JDS'} WHERE ResultClass = CIM_DataFile")
strString = "C:\Test_JDS\Test_JDS.txt"
For Each objWMIFile In objWMIFiles
If objWMIFile.FileName = LCase("Test_JDS") Then
objWMIFile.Copy strString
End If
Next
Set objWMI = Nothing
Set objWMIFile = Nothing
Set objWMIFiles = Nothing