Jump to content

DriveMapAdd Timeout?


 Share

Recommended Posts

Hey Folks,

this is my first post - so hello everyone!

iam working on network drives and sometimes the user havent set up their Data folder for sharing (its there but cant be mapped), if i try to connect to those it waits very very long to connect until windows stops the process. How can i set a timeout to DriveMapAdd or can see what happens or how can i stop it?

what i do:

DriveMapAdd('X:', '\\' & $remotePC_IP & '\Data', 0, 'user', $remotePC_Name)

what i want:

if [waittime] > 2s -> consolewrite("error') and Exit

thanks!

Johannes

Link to comment
Share on other sites

Welcome @bLophyst you could, try ping the remote ip before trying to map, for example:

If Ping($remotePC_IP, 250) Then DriveMapAdd('X:', '\\' & $remotePC_IP & '\Data', 0, 'user', $remotePC_Name)

Also you could try using builtin CMD for example (untested):

If Ping($remotePC_IP, 250) Then RunWait(@ComSpec & ' /c NET USE X: "\\' & $remotePC_IP & '\Data" /USER:User Password', "", @SW_HIDE)
If FileExists("X:") Then MsgBox(4096, "", "Drive mapping was successful")

 

Edited by Subz
Link to comment
Share on other sites

Hello :) ,

From what I understand. 

The user have to fill in your script if there is a share ? 

If so, you could check before doing anything, if there is shared folder on this computer with the registry

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanServer\Shares

After testing if the target is pinging, and if there is share present, Then 

You could consider this code 

If FileExists("X:")

Is an additional test to see if you can access to the detected share (read only), then from here you could do whatever you want. 

I add this snippet for you

Func _RegKeyExists($_sRegKey) ;Registre
    Local $sDefault = RegRead($_sRegKey, "") ;~ Try to read default value
    Switch @error
        Case 1, 2
            ;~ Unable to open requested key | Unable to open requested main key
            Return SetError(@error, 0, 'Error: Clef du Registre: "' & $_sRegKey & '"'&" N'existe pas.")
        Case Else
            ; Registry Key Exists | Return (Default) value
            Return SetError(0, 0, $sDefault)
    EndSwitch
 EndFunc

e.g. : (in this case : Checking if default key is present, default key always = "" if present)

$ScanOutlook = _RegKeyExists("HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Outlook\Profiles")
    If $ScanOutlook = "" Then $PresenceOutlook= "Oui"

About your goal, you could test just if share is present then with a for loop doing what ever you want.

And FYI you can check registry remotely. With command line.

Edited by caramen

My video tutorials : ( In construction )  || My Discord : https://discord.gg/S9AnwHw

How to Ask Help ||  UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote

Spoiler

 Water's UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...