Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: net use time out  (Read 5123 times)

0 Members and 1 Guest are viewing this topic.

dramklukkel

    Topic Starter


    Rookie

    net use time out
    « on: February 16, 2011, 06:03:30 AM »
    I want to connect to a network location and have this displayed as a drive letter S:.
    I put together some code that should look for drive S: and start the Explorer right there.
    If drive S: is not found it should try to connect to it through NET USE.
    Once connected it should fire up Explorer at S:.
    On failure it should warn.

    My problem:
    Some users are not granted acces by the IT department. When encountering this issue, the NET USE part of the program just hangs. I want it to try to connect for say half a minute, then exit, regardless of the outcome. Preferibly with a warning that sends them to IT.

    Code: [Select]
    :SFind1
    If Exist "S:" (Echo S:Allready there. >> log\%username%-Log-SearchDisk.txt&goto SRun) Else (goto SMaker)

    :SMaker
    net use S: \\sda02\ds-ib >> log\%username%-Log-SearchDisk.txt
    Echo attempt to connect to S-Disk. >> log\%username%-Log-SearchDisk.txt
    start /wait data\sleeper.vbs 1000 ,0, True
    goto SFind2

    :SFind2
    If Exist "S:" (Echo S:Now there. >> log\%username%-Log-SearchDisk.txt&goto SRun) Else (goto NoSource)

    :NoSource
    Echo Search the file "..log\%username%-Log-SearchDisk.txt"
    goto QuitFail

    :SRun
    %SystemRoot%\explorer.exe /E, S:\ >> log\%username%-Log-SearchDisk.txt
    Echo Starting Explorer S: >> log\%username%-Log-SearchDisk.txt
    goto QuitGood

    :QuitFail
    REM --------------------------------------
    Echo. >> log\%username%-Log-SearchDisk.txt
    Echo update stopped %DATE%, %TIME% >> log\%username%-Log-SearchDisk.txt
    Echo ############################### >> log\%username%-Log-SearchDisk.txt
    Echo msgbox "Ask IT for acces to this location  <tijdelijk op 'SDA02 (sda02)'(S:)>.  Show them this message." >log\%username%-fail.vbs&log\%username%-fail.vbs&del log\%username%-fail.vbs
    Exit


    :QuitGood
    REM --------------------------------------
    Echo. >> log\%username%-Log-SearchDisk.txt
    Echo update ready %DATE%, %TIME% >> log\%username%-Log-SearchDisk.txt
    Echo ############################### >> log\%username%-Log-SearchDisk.txt
    Exit

    Thanks in advance