Net use problem maping drive save credential in a work group

Answered Net use problem maping drive save credential in a work group

  • Wednesday, November 14, 2012 8:08 PM
     
     

    I am trying to map a drive in windows 7 using the net use command and save the credentials to the credentials manager.   The issue I am having is getting the correct syntax for the user.  I am not on a domain server yet, but I have mapped drives for my users.  I can't figure out what the syntax is for a local account.

    I apreciate any help.

    Here is what I got:

    net use M:10.200.143.3\elt\shared  PASSWORD /user: ?????? USER1 /savecred  /p:yes

    I am trying to mount the drive and have it save in the credential manager and be accessible after every boot. 


    Ivan Nix

All Replies

  • Thursday, November 15, 2012 10:42 AM
     
     Answered Has Code

    Ivan

    A easy solution is to use a simple script:

    See my example and replace the "declaration..." values.

    ption Explicit
    ' On Error Resume Next  													!!!!!!!! Uncomment for Debugging only - not in POD !!!!!!!!!!!!
    '
    ' Variables Declaration
    ' --------------------
    	Dim objNetwork, objFS, objShell
    	Dim strProdServer
    	Dim Letter1,Letter2
    	Dim Folder1,Folder2
    	Dim strRemotePathProd
    	Dim strUserProd,strPassword,strProfile					
    	Dim blnDebug 
    		
    ' Constantes Declaration
    ' ----------------------
    	strProdServer = "nameserver"		'File server name
    	
    ' Shares Declaration
    ' ------------------
    	Letter1 = "s:"
    	Folder1 = "\SharedFolderName1"
    	Letter2 = "T:"
    	Folder2 = "\SharedFolderName2"
    	strRemotePathProd = "\\" & strProdServer & Folder1
    
    
    ' ####  Echo for Check only ####
     ' WScript.Echo "PathProd = " & ":" & strRemotePathProd 					!!!!!!!! Uncomment for Debugging only - not in POD !!!!!!!!!!!!
    '
    ' Credentials Declaration
    ' -----------------------
    	strUserProd = "Useraccount"
    	strPassword = "userPassword"
    	strProfile = "false"
    '
    ' ####  Echo for Check only ####
    ' 	WScript.Echo "Prod Credential= " & strUserProd & " : " & strPassword 	!!!!!!!! Uncomment for Debugging only - not in POD !!!!!!!!!!!!
    					
    ' Objects Declaration	
    ' -------------------
    	Set objNetwork = wScript.CreateObject("WScript.Network")
    	Set objFs = wScript.CreateObject("Scripting.FileSystemObject")
    	Set objShell = wScript.CreateObject("WScript.Shell")
    '	
    ' Variables Assignation
    ' ---------------------
    	blnDebug = False						' Active wscript echo if True
    
    '///////////////////////////////////////////////////////
    '//  MAIN SCRIPT
    '///////////////////////////////////////////////////////
    
    	Call DeleteConnections
    	Call CreateConnections
    
    '///////////////////////////////////////////////////////
    '//  END OF SCRIPT
    '///////////////////////////////////////////////////////
    	Set objFS = Nothing
    	set objNetwork = Nothing
    	Set objShell = Nothing
    '		Troubleshooting			
    		If (blndebug = True) Then
    		WScript.echo "End"
    		End If
    	WScript.Quit
    '///////////////////////////////////////////////////////
    '//  SUB ROUTINES
    '///////////////////////////////////////////////////////
    '
    '-------------------------------------------------------
    ' Remove All Specific Existing NetWork Drives
    '-------------------------------------------------------
    Sub DeleteConnections
    	On Error Resume Next
    	objNetwork.RemoveNetworkDrive Letter1
    	objNetwork.RemoveNetworkDrive Letter2
    	On Error Goto 0
    	wScript.Sleep 250
    End sub
    
    '-------------------------------------------------------
    ' Create NetWork Drives
    '-------------------------------------------------------
    Sub CreateConnections
    	objNetwork.MapNetworkDrive Letter1,strRemotePathProd,strProfile,strUserProd,strPassword	'Drive Mapping with Password Authentication (Sample)
    	wScript.Sleep 250
    	objNetwork.MapNetworkDrive Letter2,strRemotePathProd,strProfile							'Drive Mapping without any Credential (Sample)
    	wScript.Sleep 250
    End sub
    '==============================================================================
    Regards

    Eric Malartre