I have a script that runs against remote sites to map a drive and work with a file. I use Test-Connection to make sure the remote server is alive, then attempt to map the location needed with net use. My problem is that, depending on who runs the script a certain subset of remote locations is pingable, but cannot be mapped. Is there any way to make net use time out after a shorter time, or another way to do this with Windows 7 or 2008 commands?


The correct answer is to probably figure out why they can not map the drive. To answer your question, net use does not have a time out command:

C:\Users\user>net use /? The syntax of this command is:

NET USE [devicename | *] [\computername\sharename[\volume] [password | *]]

    [/USER:[domainname\]username]
    [/USER:[dotted domain name\]username]
    [/USER:[username@dotted domain name]
    [/SMARTCARD]
    [/SAVECRED]
    [[/DELETE] | [/PERSISTENT:{YES | NO}]]

NET USE {devicename | *} [password | *] /HOME

NET USE [/PERSISTENT:{YES | NO}]

However if you want your script to keep on moving while your net use command figures it's self out you could use the start command to launch it in a new window and the normal script should be able to keep doing what ever you want it to do. start net use \\\computername\sharename x:


start your Timer run NET USE with "start" as supposed. send your Batch into a loop

  • check if the netshare is already connected.
  • If yes Exit loop,
  • if not check if timer has exceeded
    • if yes - Echo Error and exit Do what you want to do :)

Kind regards Johannes