Jump to content
Sign in to follow this  
GoogleDude

MapDrive question?

Recommended Posts

GoogleDude

I have a simple script that assensialy maps a network drive. this compiled script is located in ALL Users Startup Folder in the start menu. The problem is that I dont care what drive letter gets assigned but I do want it to exist. And I want it to run this script for all users.

Since Using the "*" in the drive letter field will assign what ever avail. driver letter. How can I avoid remapping the same path to a new drive letter that is unused at each login?

~GD

Share this post


Link to post
Share on other sites
Steveiwonder

You could just setup the drive once using Tools>Map Network Drive and check the box "Reconnect at Login".

You then don't need a script and do not need to worry about re-mapping the same drive.

or

If DriveStatus("\\Server\Share") <> "READY" Then    
     DriveMapAdd("*", "\\Server\Share")      
EndIf
Edited by Steveiwonder

They call me MrRegExpMan

Share this post


Link to post
Share on other sites
GoogleDude

You could just setup the drive once using Tools>Map Network Drive and check the box "Reconnect at Login".

You then don't need a script and do not need to worry about re-mapping the same drive.

or

If DriveStatus("\\Server\Share") <> "READY" Then    
 DriveMapAdd("*", "\\Server\Share") 
EndIf

Thanks for the reply. System is on a domain with several hundred users that might log into windows. logging in as each user manually at least once and setting up the drive mapping is not really an option unfortunately. That's why I figured the all users startup folder in the start menu. Each domain user has different drive mapped in there domain login so I cant manually set a drive, But want to make sure a new drive letter is not mapped each time that user logs in. Maybe im going about this the hard way (totally possible).

I can get the the drive path mapped at login of anyone that's not the problem. The problem is how can I check all drive letters that are avail to see if a folder exist or not, not knowing what the drive letter that was assigned by the previous login?

Thanks again for any feedback,

~GD

Edited by GoogleDude

Share this post


Link to post
Share on other sites
Steveiwonder

If im understanding you correctly?

Multiple domains, and each domain has different drive mapping..

I see it like this...

Domain1: \\Server1\Share

Domain2: \\Server2\Share

Domain3: \\Server3\Share

Switch @LogonDomain

    Case "Domain1"
        If Not FileExists("\\Server1\Share") Then
            DriveMapAdd("*", "\\Server1\Share")
        EndIf

    Case "Domain2"
        If Not FileExists("\\Server2\Share") Then
            DriveMapAdd("*", "\\Server2\Share")
        EndIf

    Case "Domain3"
        If Not FileExists("\\Server3\Share") Then
            DriveMapAdd("*", "\\Server3\Share")
        EndIf

EndSwitch

I may have missunderstood you but this is what im thinking?

Let me know.

Steve

EDIT: Typo's cos im a spastic

Edited by Steveiwonder

They call me MrRegExpMan

Share this post


Link to post
Share on other sites
99ojo

Hi,

i get this out of the topic:

;Foldername to check on target networkdrive
$checkfolder = "foldername" ; you may check for a file as well, e.g: "MyFolder\My.exe"
;get all mapped drive letters
$ardrives = DriveGetDrive ("NETWORK")
;check boolean
$found = False
;Loop over array of mapped drives
For $i = 1 To UBound ($ardrives) - 1
    ;checking if folder exist on mapped drives, if yes -> check boolean = TRUE -> exit loop
    If FileExists ($ardrives [$i] & "\" & $checkfolder) Then
        $found = True
        ExitLoop
    EndIf
Next
;Folder not found, map first free drive letter to network share
If Not $found Then DriveMapAdd("*", "\\Server\Share")

;-))

Stefan

Edited by 99ojo

Share this post


Link to post
Share on other sites
Yoriz

To check for an already mapped drive use 'DriveGetDrive ("NETWORK")' to recieve an array of available network drive letters, loop through the returned array with DriveMapGet (returnedArray[loopPos]) and check against your \\Server1\Share.

$hNetworkDrive = ""
$aDriveLetters = DriveGetDrive( "NETWORK" )
If NOT @error Then
    For $i = 1 to $aDriveLetters[0]
        If DriveMapGet($aDriveLetters[$i]) = "\\Server1\Share" Then 
        $hNetworkDrive = $aDriveLetters[$i]
        ExitLoop
    Next
    If $hNetworkDrive = "" Then $hNetworkDrive = DriveMapAdd("*","\\Server1\Share",1)
Else
    MsgBox(0,"Error","No network drives found")
EndIf

GDIPlusDispose - A modified version of GDIPlus that auto disposes of its own objects before shutdown of the Dll using the same function Syntax as the original.EzMySql UDF - Use MySql Databases with autoit with syntax similar to SQLite UDF.

Share this post


Link to post
Share on other sites
GoogleDude

Hi,

i get this out of the topic:

;Foldername to check on target networkdrive
$checkfolder = "foldername" ; you may check for a file as well, e.g: "MyFolder\My.exe"
;get all mapped drive letters
$ardrives = DriveGetDrive ("NETWORK")
;check boolean
$found = False
;Loop over array of mapped drives
For $i = 1 To UBound ($ardrives) - 1
    ;checking if folder exist on mapped drives, if yes -> check boolean = TRUE -> exit loop
    If FileExists ($ardrives [$i] & "\" & $checkfolder) Then
        $found = True
        ExitLoop
    EndIf
Next
;Folder not found, map first free drive letter to network share
If Not $found Then DriveMapAdd("*", "\\Server\Share")

;-))

Stefan

This does the trick. Thank you very much. I can play with this to tweak it as I need. Thanks again.

~GD

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.