JusGellin Posted October 3, 2007 Share Posted October 3, 2007 I found some code on this site that suggested how to rename mapped drives, but doesn't seem to work for me. What am I doing wrong and how can I troubleshoot to make this work in Autoit? - Thanks $driveLetter = "X:" $RemoteShare = "\\RemoteName\c$" DriveMapDel( $driveLetter ) DriveMapAdd($driveLetter, $RemoteShare) $oShell = ObjCreate("shell.application") $oShell.NameSpace($driveLetter).Self.Name = "New Name c$" MsgBox(0,"Mapped Share","Completed") I found some code in vbs that works, but I would like to strictly do it in Autoit: Option Explicit Dim objNetwork, strDrive, objShell, objUNC Dim strRemotePath, strDriveLetter, strNewName ' strDriveLetter = "Y:" strRemotePath = "\\RemoteName\c$" strNewName = "New Name c$ ver2" ' Section to map the network drive Set objNetwork = CreateObject("WScript.Network") objNetwork.MapNetworkDrive strDriveLetter, strRemotePath ' Section which actually (re)names the Mapped Drive Set objShell = CreateObject("Shell.Application") objShell.NameSpace(strDriveLetter).Self.Name = strNewName Wscript.Echo "Check : "& strDriveLetter & " for " & strNewName WScript.Quit ' End of script. Link to comment Share on other sites More sharing options...
Matrix112 Posted October 3, 2007 Share Posted October 3, 2007 (edited) I think this can be more easy, try following console command net use <drive:> \\<Servername>\<sharingname> You can make an AutoIt script, using : Run(@ComSpec & " /c " & 'net use x: \\servername\sharename', "", @SW_HIDE) Edited October 3, 2007 by Matrix112 Link to comment Share on other sites More sharing options...
JusGellin Posted October 3, 2007 Author Share Posted October 3, 2007 Thanks, I knew how to map a drive. I wanted to rename that mapped drive on my local machine with a new readable name like the vbs does. Link to comment Share on other sites More sharing options...
ptrex Posted October 4, 2007 Share Posted October 4, 2007 @JusGellin This works for me, Dim $objNetwork, $strDrive, $objShell, $objUNC Dim $strRemotePath, $strDriveLetter, $strNewName $strDriveLetter = "Z:" $strRemotePath = "\\SERVER\Sharename$" $strNewName = "New Name c$ ver2" ; Section to map the network drive $objNetwork = ObjCreate("WScript.Network") $objNetwork.MapNetworkDrive ($strDriveLetter, $strRemotePath) ; Section which actually (re)names the Mapped Drive $objShell = ObjCreate("Shell.Application") $objShell.NameSpace($strDriveLetter).Self.Name = $strNewName ConsoleWrite( "Check : " & $strDriveLetter & " for " & $strNewName & @CRLF) regards ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
JusGellin Posted October 4, 2007 Author Share Posted October 4, 2007 Thanks for trying this. After I saw your success, I looked further and found that for some reason certain drive letters were not updating with a new name. It just so happened that the one I was testing was the one that wouldn't update with a new name. But when I tried other mapped drive letters it would work. Also my original as well as your code would work. I'm just not sure why some drive letters don't seem to get the rename even if I refresh or when I bring up windows explorer fresh again. Thanks again Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now