?
Solved

I try to delete a remote shares by VBS

Posted on 2009-04-08
6
Medium Priority
?
298 Views
Last Modified: 2012-06-22
Greetings, - )
I want to delete a remote share. I started from trying to delete local share with this code:
(look at the code)

This is a part of code (I exclused the part where I write to log file my results).

So when I opened my log file I see that all my shares where found but they are not deleted.

I tried to use "If Err.Number <> 0 Then"
but it didn't help.

I try to run it on MS Vista.
0
Comment
Question by:Master-Squirrel
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
6 Comments
 

Author Comment

by:Master-Squirrel
ID: 24095378
Hm...
That is my code:

Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set colShares = objWMIService.ExecQuery("Select * from Win32_Share")
   
      
For Each ShareItem in colShares
            ShareItem.Delete                                    
Next
0
 

Author Comment

by:Master-Squirrel
ID: 24095919
Hmmm...It works only on XP. Why?
0
 
LVL 15

Accepted Solution

by:
qz8dsw earned 1000 total points
ID: 24110956
I would say your coming up against Vista's UAC.
You could try using UAC Elevation (as per http://www.winhelponline.com/articles/185/1/VBScripts-and-UAC-elevation.html)
Or as per another post on EE disable it completely (depending on your situation).
http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/Windows/Windows_Vista/Q_22833413.html
0
 

Author Comment

by:Master-Squirrel
ID: 24117442
Great thanks! It works!!
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have done a reformat of your hard drive and proceeded to do a successful Windows XP installation, you may notice that a choice between two operating systems when you start up the machine. Here is how to get rid of this: Click Start Clic…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
The Task Scheduler is a powerful tool that is built into Windows. It allows you to schedule tasks (actions) on a recurring basis, such as hourly, daily, weekly, monthly, at log on, at startup, on idle, etc. This video Micro Tutorial is a brief intro…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question