Discussion:
Using WMI to determine if directory is shared
(too old to reply)
lcaverly
2009-08-26 13:20:38 UTC
Permalink
Hi,
I wanted to see if the current directory is enabled as a shared
folder in 4NT8 under XP.

Having never used the WMI (Windows Management Instrumentation), I
decided to use this for determining if the current directory is
enabled as a shared folder in 4NT8.

I came up with the following .BTM

@setlocal
@if %_echo eq 1 @echo off
if defined thisdir unset thisdir
set thisdir=%@wmi[root\cimv2,"select Name from Win32_Share Where Path
= '%@replace[\,\\,%_cwd]'"]
if defined thisdir echo %_cwd is shared as %thisdir
if not defined thisdir echo %_cwd is not shared
endlocal

I learned quite a bit about WMI for this task.

Note the Path = '%@replace[\,\\,%_cwd]'"

Since Path is not a Key, I have to use double-backslashes in the
directory name. So,

C:\utils\example becomes

C:\\utils\\example

The Path property indicates the local path of the Win32 share.

The Win32_Share class has methods which allow you to create a share,
delete a share, determine the access rights to the share, and to set
share info. Each method also has qualifiers to obtain more information
in regards to the share.

As noted in the 4NT8 help file, download the "WMI Code Creator" from
Microsoft. This is a GUI front-end for WMI, that creates code for C#,
Visual Basic .NET, and Visual Basic Script, and was quite useful in
learning about WMI.

Joe
E. S. Fabian
2009-08-26 15:31:53 UTC
Permalink
lcaverly wrote:
| I wanted to see if the current directory is enabled as a shared
| folder in 4NT8 under XP.

Your messages relating to 4NT8 usage really should go to the JPsoft forum TC
tips (my abbreviation of the forum name), in this instance either to the
"miscellaneous" or the "scripting" subforum. Just because it does not
require the latest released version (10.0, build 75) it will work in any
version back to the earliest one which supports @WMI (which happens to be
V8, your own version). I regularly use 4nt8 and TCC9, esp. when I need to
use one of my best-than-anything-for-windows PC-DOS (16b) tools.

Nobody here in the comp.os.msdos.4dos NG objects, because there is very
little interest left in 4DOS, and I suspect very few bother to read the NG.
--
Steve
Loading...