Solved

I try to delete a remote shares by VBS

Posted on 2009-04-08
6
295 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 250 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
When you try to extract and to view the contents of a Microsoft Update Standalone Package (MSU) for Windows Vista, you cannot extract the files from the MSU. Here we are going to explain how to extract those hotfix details without using any third pa…
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…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

719 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