Jump to content

Search the Community

Showing results for tags 'drivemapadd drivemapdel label'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 1 result

  1. I check for an existing drive mapping on X using FileExists("X:") save it to a variable then map the path I need to X if DriveMapAdd("X:",$sDataPath,8,$sAuth,$sAuth) = 0 then _errDriveMapAdd(@error,@extended) once I'm finished with the mapped drive I return it to it's original mapping with _errDriveMapDel(DriveMapDel("X:")) if DriveMapAdd("X:",$sDataPath,8,$sAuth,$sAuth) = 0 then _errDriveMapAdd(@error,@extended) and below are the error checking functions func _errDriveMapDel($iRetVal) if $iRetVal = 0 Then msgbox(16,"ERROR - Drive Map Del","Unable to delete existing drive mapping - closing app") Exit EndIf EndFunc func _errDriveMapAdd($iError,$iExtended) $sTitle = "ERROR - Drive Map Add" Switch $iError Case 1 msgbox(16,$sTitle,"Undetermined Cause - Windows API returns error: " & $iExtended) Case 2 msgbox(16,$sTitle,"Access to the remote share was denied") Case 3 msgbox(16,$sTitle,"The drive letter or device is already assigned") Case 4 msgbox(16,$sTitle,"Invalid device name (must be a letter a-Z)") Case 5 msgbox(16,$sTitle,"Invalid remote share (bad path)") Case 6 msgbox(16,$sTitle,"Invalid password") EndSwitch Exit EndFunc The problem is that the drive labels in Windows Explorer are not changing when this drive mapping changes. The mapped drive points correctly to the new location but in Explorer it still shows the old drive label. Is there some way to force this to refresh? (note that starting a new instance of explorer still shows the old drive label also). Below is the full program: #cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.9.21 (Beta) Author: GruntyDatsun Script Function: Check if there is an existing X drive mapping, if so record it Remap X drive to \\server\path Launch APP On close of APP, remove the x drive mapping to \\server\path Restore pre-existing x drive mapping, if there was one 0.3 changed cmd map add/drops to DriveMapAdd and DriveMapDel added error detection and feedback ;~ problem: if there is an existing process using data in a mapped drive the windows command cannot unmap it. #ce ----------------------------------------------------------------------------ss local $sOldMap = "" local const $sAppPath = "G:\path\to\application" local const $sDataPath = "\\server\path\to\data" local const $sAuth = "user_same_as_pw_Shame" Switch FileExists("X:") Case 0 ;no existing x drive mapping - just map it if DriveMapAdd("X:",$sDataPath,8,$sAuth,$sAuth) = 0 then _errDriveMapAdd(@error,@extended) ;add drive mapping Case 1 $sOldMap = DriveMapGet("X:") ;get path of existing drive mapping if $sOldMap <> $sDataPath then ;if existing drive path matches proposed drive path _errDriveMapDel(DriveMapDel("X:")) ;delete existing drive mapping if DriveMapAdd("X:",$sDataPath,8,$sAuth,$sAuth) = 0 then _errDriveMapAdd(@error,@extended) ;add drive mapping EndIf EndSwitch if FileExists($sAppPath & "\APP.exe") Then ;if iSYS app exists on this path RunWait($sAppPath & "\APP.exe",$sAppPath) ;run iSYS app Else msgbox(16,"ERROR - Running iSYS","iSYS is not available on network path: " & $sAppPath & "\APP.exe") ;warn iSYS app not available on proposed path Exit EndIf func _errDriveMapDel($iRetVal) if $iRetVal = 0 Then msgbox(16,"ERROR - Drive Map Del","Unable to delete existing drive mapping - closing app") Exit EndIf EndFunc func _errDriveMapAdd($iError,$iExtended) $sTitle = "ERROR - Drive Map Add" Switch $iError Case 1 msgbox(16,$sTitle,"Undetermined Cause - Windows API returns error: " & $iExtended) Case 2 msgbox(16,$sTitle,"Access to the remote share was denied") Case 3 msgbox(16,$sTitle,"The drive letter or device is already assigned") Case 4 msgbox(16,$sTitle,"Invalid device name (must be a letter a-Z)") Case 5 msgbox(16,$sTitle,"Invalid remote share (bad path)") Case 6 msgbox(16,$sTitle,"Invalid password") EndSwitch Exit EndFunc
×
×
  • Create New...