PDA

View Full Version : Password Protected drives



rockhpi
02-26-2010, 01:24 PM
I am running an excel Macro that goes out to 7 different network drives to pull files and combine them into one. The problem is, the drives are all password protected, so each day I have to go to "My Computer", click on each drive and enter the password for each so that when the macro runs I don't get "Path not found".

Is there a way I can enter the passwords in the code so I don't have to manually enter them?

hardlife
02-27-2010, 11:03 AM
May be dos commands could do it? :hi:


example:


Sub testDOSCommands()

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("WScript.Shell")

DOSCommands = "cd C:" & vbCrLf & _
"cd \" & vbCrLf & _
"md test"

MsgBox DOSCommands

Set objDOSFile = objFSO.CreateTextFile("DOSCommands.bat", 1)
objDOSFile.Write DOSCommands
objDOSFile.Close

strCommand = "cmd /c DOSCommands.bat "

objShell.Run strCommand, 0, True
objFSO.DeleteFile "DOSCommands.bat", 1

MsgBox "OK"

Set objShell = Nothing
Set objFSO = Nothing

End Sub

but You must find Your dos commands :-)

http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/net_use.mspx?mfr=true

http://www.computing.net/answers/windows-nt/net-use-command/15710.html

Hope this helps.