Top DevX Stories
Creating Custom Export Filters for StarOffice with XSLT
WPF Wonders: Using DataTemplates
Crystal Reports Family Offers Options for Developers
Avaya Aura Session Manager video
Avaya Aura Overview video
Search the forums:
  #1  
Old 04-13-2006, 06:55 AM
buligi buligi is offline
Registered User
 
Join Date: Oct 2005
Posts: 8
Shell ("net use " )

Hi to all.

I need to map a drive on the net with vb6

I'm using the command

Shell ("net use 192.168.254.254 /USER:administrator ")

but the password is blank

Using this shell the command line responds to enter a valid password, and if I press the enter key the drive is mapped correctly

How do can I pass the password?

thank You in advance for any help.

Buligi
Reply With Quote
  #2  
Old 04-13-2006, 08:07 AM
Sync Sync is offline
Senior Member
 
Join Date: Dec 2004
Posts: 717
Code:
The syntax of this command is:

NET USE
[devicename | *] [\\computername\sharename[\volume] [password | *]]
        [/USER:[domainname\]username]
 
       [/USER:[dotted domain name\]username]
        [/USER:[username@dotted domain name]
        [/SMARTCARD]
        [/SAVECRED]
        [[/DELETE] | [/PERSISTENT:{YES | NO}]]

NET USE {devicename | *} [password | *] /HOME

NET USE [/PERSISTENT:{YES | NO}]
or

Class Name : NetworkServices
Code:
Private Type NETRESOURCE
        dwScope As Long
        dwType As Long
        dwDisplayType As Long
        dwUsage As Long
        lpLocalName As String
        lpRemoteName As String
        lpComment As String
        lpProvider As String
End Type

Private Declare Function WNetAddConnection2 Lib "mpr.dll" Alias "WNetAddConnection2A" (lpNetResource As NETRESOURCE, ByVal lpPassword As String, ByVal lpUserName As String, ByVal dwFlags As Long) As Long
Private Declare Function WNetCancelConnection2 Lib "mpr.dll" Alias "WNetCancelConnection2A" (ByVal lpName As String, ByVal dwFlags As Long, ByVal fForce As Long) As Long
Private Declare Function WNetGetUser Lib "mpr.dll" Alias "WNetGetUserA" (ByVal lpName As String, ByVal lpUserName As String, lpnLength As Long) As Long


Public Function UserName(Optional strLocalPath As String = "")

   Dim strBuffer As String * 255
   Dim lngReturn As Long

   lngReturn = WNetGetUser(strLocalPath, strBuffer, 255)
   UserName = Trim(strBuffer)

   If lngReturn <> 0 Then
      Err.Raise vbObjectError, "NetworkServices.UserName", _
         "Error #" & lngReturn & " occurred during request."
   End If
   

End Function

Public Sub DropConnection(strLocalPath As String, Optional blnForce As Boolean = False)

   Dim lngReturn As Long

   lngReturn = WNetCancelConnection2(strLocalPath, 0, blnForce)

   If lngReturn <> 0 Then
      Err.Raise vbObjectError, "NetworkServices.DropConnection", "Error #" & lngReturn & " occurred during connection drop."
   End If

End Sub


Public Sub AddConnection(strLocalPath As String, strNetworkPath As String, _
   Optional strUserName As String = "", Optional strPassword As String = "")
   
   Dim typNet As NETRESOURCE
   Dim lngReturn As Long

   With typNet
      .dwType = RESOURCETYPE_DISK
      .lpLocalName = strLocalPath
      .lpRemoteName = strNetworkPath
      .lpProvider = ""
   End With

   lngReturn = WNetAddConnection2(typNet, strPassword, strUserName, 0)

   If lngReturn <> 0 Then
      Err.Raise vbObjectError, "NetworkServices.AddConnection", "Error #" & lngReturn & " occurred during connection."
   End If
   
End Sub
usage:
Code:
Dim objNet As NetworkServices

Set objNet = New NetworkServices
objNet.AddConnection "F:", "\\Server\C$", "domainname\usr", ""
MsgBox objNet.UserName
''objNet.DropConnection "F:"
Building a Network Service Object
http://www.devx.com/getHelpOn/10MinuteSolution/20405
Map a network drive
http://www.vb-helper.com/howto_map_network_drive.html

[code]
Set objNetwork = CreateObject("WScript.Network")
strDriveLetter = "DriveLetter:"
strHomeServer = "\\server\share"
objNetwork.MapNetworkDrive strDriveLetter, strHomeServer
[code]

http://207.150.176.83/archive/index.php?t-45632.html
http://www.vbforums.com/showthread.php?p=2425036#post2425036


Try.. Hope it works.....
__________________
Best Regards,
Michael Sync
http://michaelsync.net

The more you share,The more you get

Last edited by Sync; 04-13-2006 at 08:10 AM.
Reply With Quote
Reply

Bookmarks

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Trouble using CALL SHELL() kevin3306 VB Classic 4 09-15-2005 07:32 PM
Shell Program none_none C++ 13 04-19-2005 06:20 PM
Shell and Wait Converted to VB.Net - November 2002 Tip of the Month Larry Rebich dotnet.announcements 0 10-15-2002 02:20 PM
Shell Hook without Shell? Juergen Thuemmler VB Classic 2 06-22-2000 11:31 AM
Shell Hook without Shell? Juergen Thuemmler VB Classic 0 06-22-2000 05:12 AM


All times are GMT -4. The time now is 02:24 AM.


Sponsored Links



Acceptable Use Policy

internet.comMediabistrojusttechjobs.comGraphics.com

WebMediaBrands Corporate Info


Advertise | Newsletters | Feedback | Submit News

Legal Notices | Licensing | Permissions | Privacy Policy


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.