Jump to content

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



Link to post
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 post
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


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)

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


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

ADO - Wiki


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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...