Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 12th, 2012, 08:57 PM
TASB TASB is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2009
Posts: 155 TASB User rank is Second Lieutenant (5000 - 10000 Reputation Level)TASB User rank is Second Lieutenant (5000 - 10000 Reputation Level)TASB User rank is Second Lieutenant (5000 - 10000 Reputation Level)TASB User rank is Second Lieutenant (5000 - 10000 Reputation Level)TASB User rank is Second Lieutenant (5000 - 10000 Reputation Level)TASB User rank is Second Lieutenant (5000 - 10000 Reputation Level)TASB User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 4 Days 8 h 9 m 7 sec
Reputation Power: 88
Problem with winmgmts

Hi, the following code works. If you enter a non existant directory for strFolderName it will err with 424.

Code:
On Error Resume Next

strFolderName = "C:\test"
Set objWMIService = GetObject("winmgmts:")
Set objFolderSecuritySettings = objWMIService.Get("Win32_LogicalFileSecuritySetting='" & strFolderName & "'")
intRetVal = objFolderSecuritySettings.GetSecurityDescriptor(objSD)

If err.number = 424 Then 
	MsgBox err.number
End If
err.clear




The following code does not work

Code:
'On Error Resume Next

test()

Sub test()
	strFolderName = "C:\test"
	Set objWMIService = GetObject("winmgmts:")
	Set objFolderSecuritySettings = objWMIService.Get("Win32_LogicalFileSecuritySetting='" & strFolderName & "'")
	info = objFolderSecuritySettings.GetSecurityDescriptor(objSD)
	
	If err.number = 424 Then 
		MsgBox err.number
	End If
	err.clear


End Sub


Error test2.vbs(8, 2) SWbemServicesEx: Not found

I need run the code within a function or sub but whenever I put it in one the error comes up.

Please do not reply saying there is an easyer way to check is a directory exists because that is not the goal of the script.

Reply With Quote
  #2  
Old December 13th, 2012, 01:57 AM
couttsj couttsj is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2011
Posts: 178 couttsj User rank is Sergeant Major (2000 - 5000 Reputation Level)couttsj User rank is Sergeant Major (2000 - 5000 Reputation Level)couttsj User rank is Sergeant Major (2000 - 5000 Reputation Level)couttsj User rank is Sergeant Major (2000 - 5000 Reputation Level)couttsj User rank is Sergeant Major (2000 - 5000 Reputation Level)couttsj User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 2 Days 22 h 6 m 57 sec
Reputation Power: 43
Your code:
Code:
Private Sub Command1_Click()
    On Error GoTo cmdErr
    strFolderName = "C:\test"
    Set objWMIService = GetObject("winmgmts:")
    Set objFolderSecuritySettings = objWMIService.Get("Win32_LogicalFileSecuritySetting='" & strFolderName & "'")
    intRetVal = objFolderSecuritySettings.GetSecurityDescriptor(objSD)
    Exit Sub
cmdErr:
        MsgBox "Error " & Str$(Err) & ": " & Error$(Err)
End Sub

returns this error:
Error -2147217406: Not found

J.A. Coutts

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > Problem with winmgmts

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap