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.
: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