GetObject("winmgmts:{impersonationLevel=impersonate}").InstancesOf("Win32_LogicalDisk").
It is error in method to query the list folders information of the remote server.
Error message :"Cannot create ActiveX component."
When call method: GetObject("winmgmts:{impersonationLevel=impersonate}!\\test1\root\cimv2").InstancesOf("Win32_LogicalDisk").
My machine OS is windows 2000 professional ,it is on domain and implement with VB.NET. Thank you for your help
Best regards,
Trojan
***************************************************************************************************************
Hi,
I am writing a small application in order to backup and restore database into file using SQL-DMO.
The program is supposed to run on any machine.
I have a little problem for backup and restore remote database because I don't know what object should I use to obtain a folder list for the destination file on the remote machine so that it list the folders on remote machine virtually local (C:\,D:\,...) like when we use enterprise manager to perform backup and restore from the remote server.
How can I check for the permission that we have the authorization to create the backup file on the remote machine?
Best regards,
Trojan
**************************************************************************************
Hi Trojan,
Thanks for posting in the community!
From your description, I understand that you would like to know if there
are SQL-DMO objects can list the folders on the remote machine virtually
local path and check the permission for the backup file creation on the
remote machine.
Based on my experience, SQL-DMO has no such objects to implement this. This
task should and can gracefully be done by Win32 WMI, with which I'm not be
so familiar. I researched and found that you might be able to use the
following method to query the list folders information of the remote server.
GetObject("winmgmts:{impersonationLevel=impersonate}!\\<remote_server>\rootcimv2").InstancesOf("Win32_LogicalDisk"). Please see the following sample
code for more information and apply the principle onto your application.
Note that the following code is just a simple example and you should query
all the information within the folder when users click on it, instead of
loop to query all the information at first.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''
Private Sub wmiLogicalDiskInfo()
Dim wbemLocator As New WbemScripting.SWbemLocator
Dim wbemServices As SWbemServices
Dim wbemObject As SWbemObject
Dim wbemObjectSet As SWbemObjectSet
Dim wbemObjectInstance As SWbemObject
Dim LogicalDiskSet As SWbemObjectSet
Dim dirs As SWbemObjectSet
Dim subdirs As SWbemObjectSet
Dim lds As SWbemObject
Dim sublds As SWbemObject
Dim itmx As ListItem
Dim subdir As SWbemObject
Dim msg As String
'Must have error handler enabled, as all
'disks do not return all information
On Local Error Resume Next
Set LogicalDiskSet =
GetObject("winmgmts:{impersonationLevel=impersonate}!\\<remote_server>\rootcimv2").InstancesOf("Win32_LogicalDisk")
For Each lds In LogicalDiskSet
For Each wbemObject In
lds.Associators_("Win32_LogicalDiskRootDirectory")
For Each sublds In wbemObject.Associators_("Win32_SubDirectory")
For Each subdir In sublds.Associators_("Win32_SubDirectory")
' For Each subdir In
sublds.Associators_("Win32_SubDirectory")
Debug.Print subdir.Name
Next
Next
Next
Set itmx = ListView1.ListItems.Add(, , lds.Caption)
If Not IsNull(lds.DriveType) Then
msg = CStr(lds.DriveType)
Select Case lds.DriveType
Case 1: msg = msg & " (unknown)"
Case 2: msg = msg & " (removable)"
Case 3: msg = msg & " (local)"
Case 4: msg = msg & " (network)"
Case 5: msg = msg & " (cd)"
Case 6: msg = msg & " (ramdisk)"
End Select
itmx.SubItems(1) = msg
End If
If Not IsNull(lds.FileSystem) Then
itmx.SubItems(2) = lds.FileSystem
End If
If Not IsNull(lds.MediaType) Then
msg = CStr(lds.MediaType)
Select Case lds.MediaType
Case 0: msg = msg & " (format unknown)"
Case 1: msg = msg & " (51/4 floppy 1.2mb)"
Case 2: msg = msg & " (31/2 floppy 1.44mb)"
Case 3: msg = msg & " (31/2 floppy 2.88mb)"
Case 4: msg = msg & " (31/2 floppy 20.8mb)"
Case 5: msg = msg & " (31/2 floppy 720kb)"
Case 6: msg = msg & " (51/4 floppy 360kb)"
Case 7: msg = msg & " (51/4 floppy 320kb)"
Case 8: msg = msg & " (51/4 floppy 320kb)"
Case 9: msg = msg & " (51/4 floppy 180kb)"
Case 10: msg = msg & " (51/4 floppy 160kb)"
Case 11: msg = msg & " (removable)"
Case 12: msg = msg & " (fixed disk)"
Case 13: msg = msg & " (31/2 floppy 120mb)"
Case 14: msg = msg & " (31/2 floppy 640kb)"
Case 15: msg = msg & " (51/4 floppy 640kb)"
Case 16: msg = msg & " (51/4 floppy 720kb)"
Case 17: msg = msg & " (31/2 floppy 1.2mb)"
Case 18: msg = msg & " (31/2 floppy 1.23mb)"
Case 19: msg = msg & " (51/4 floppy 1.23mb)"
Case 20: msg = msg & " (31/2 floppy 128mb)"
Case 22: msg = msg & " (8 floppy 256kb)"
End Select
itmx.SubItems(3) = msg
End If
If Not IsNull(lds.FreeSpace) Then
itmx.SubItems(4) = FormatNumber(lds.FreeSpace, 0)
End If
If Not IsNull(lds.VolumeName) Then
itmx.SubItems(5) = lds.VolumeName
End If
If Not IsNull(lds.VolumeSerialNumber) Then
itmx.SubItems(6) = lds.VolumeSerialNumber
End If
If Not IsNull(lds.Description) Then
itmx.SubItems(7) = lds.Description
End If
Next
End Sub
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''
In addition, if you would, please post this question in the corresponding
newsgroup which handling WMI issue. The reason why we recommend posting
appropriately is you will get the most qualified pool of respondents, and
other partners who read the newsgroups regularly can either share their
knowledge or learn from your interaction with us. Thank you!
Regards,
Billy Yao
Microsoft Online Support
***************************************************************************************
--
-Philip
This posting is provided "As Is" with no warranties, and confers no rights.
"Tro...@dis.cc" <anon...@discussions.microsoft.com> wrote in message
news:1B0DE715-521A-4854...@microsoft.com...
GetObject("winmgmts:{impersonationLevel=impersonate}!\\<remote_server>\rootc
--
-Philip
This posting is provided "As Is" with no warranties, and confers no rights.
<tro...@dis.cc> wrote in message
news:408B7BEF-94EF-4C47...@microsoft.com...
> Source machine is WinXP SP1 and target machine is WIN2000 SP2.
>
> How can I configure the target machine.
>
> Thanks.