Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Net Use to map a drive?
Message
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00146250
Message ID:
00146565
Views:
29
>>>Is there an API to map a Windows NT network drive letter? Similar to the NET USE dos prompt command.
>>
>>In addition to the API stuff mentioned by others, the Windows Scripting Host (native to 98, and addable to other operating systems by running the self-installing WSH.EXE available from Microsoft's Web site) provides a network automation object. If WSHOM.OCX has been registered, the following works:
>>
>>
>>oWshNet = CREATEOBJ('Wscript.Network')
>>*  Lots of arguments available here:
>>*  cLocalDrive is the local resource name (eg 'N:')
>>*  cRemoteName is the UNC of the path you want to map
>>*  (optional)  lUpdateProfile (bool) if .T., save the mapping
>>*  (optional)  cUserId the name of a user other than the default
>>*              Windows Login userid for accessing UNC
>>*  (optional)  cPassword password for user accessing UNC
>>oWshNet.MapNetworkDrive(cLocalDrive, cRemoteName)
>>*
>>*  You can unmap a drive by:
>>*
>>oWshNet.RemoveNetworkDrive(cLocalDrive)
>>
>
>Here's some more scripts that might be useful at:
>
>http://cwashington.netreach.net/site/scripts/scripts_index.html

Thanks for the reference, John. What I'm doing at this point is incorporating the use of the support objects from Wscript and scripting-related automation objects into VFP - in particular, the Wscript.Shell, Wscript.Network, and the various ADSI components are incredibly useful in accessing things in various APIs that would otherwise require wrapper .DLLs and significant coding to make their functions available; for example, getting the functionality of WNetAddConnection2() rather than WNetAddConnection(), is much easier using the Wscript.Network object than writing the wrappers needed to make the API call itself.

I'm playing a bit with the ADSI 2.5 object set, and will let you know how it goes making that available to VFP as well. The biggest issue I have is in ensuring that it installs properly - Wscript is a piece of cake, since it can install cross-platform unambiguously, but ADSI is a bit trickier to get set up right.
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform