Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Other Programming > VBScript
VBScript For questions and discussions related to VBScript.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VBScript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old July 2nd, 2007, 06:53 AM
Registered User
Join Date: Jun 2007
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default issue in finding the share

Hi ,

I'm not able to find wether a particular share exists or not in a server.

I use a script.

Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate,authenticationLev el=Pkt}!\\"_
    & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_Share where Name = '"&"sharename"&"'")

    If (colItems.Count = 1) then
        Wscript.Echo "The share exists"
        Wscript.Echo "The share does not exists"
    End If

to find wether share exists or not this script works fine on all the servers except one. It gives error "Provider load failure"
I checked the "WMI controls" permissions , DCOM permissions and gave full rights. I even tried to raise the security level in the code using

Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")
Set objWMIService = objSWbemLocator.ConnectServer (strComputer, "root\CIMV2", username, Password)
objWMIService.Security_.impersonationlevel = 3

Still I'm not able to get the share name from the server.
Am I missing any thing? . or if any one has any suggessions please let me know.

Reply With Quote
  #2 (permalink)  
Old July 4th, 2007, 07:45 AM
Registered User
Join Date: Jun 2007
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts

Thanks anyways,
I have resolved the issue.
Its because the WMI services and its dependent SMS agent host services were not working properly. so restarted the services and ran the script it worked fine.
If anyone has the same issue you can resolve it by this way.

Reply With Quote

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem Backing Up to Share rstelma SQL Server 2005 1 July 18th, 2008 04:20 PM
how can share my databse lalit_84m SQL Server 2000 1 May 31st, 2007 01:05 AM
How to share along several projects Demeter Visual Studio 2005 2 July 14th, 2006 07:49 AM
Why do we share knowledge online? nz_boy General .NET 0 March 27th, 2006 05:55 AM
how to share a folder mqnguyen Classic ASP Basics 2 August 6th, 2003 01:23 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.