>>No, but there are at least a couple of workarounds:
>>
>>1. You can always delete the mapping first, that causes no harm if it doesn't exist i.e.
>>
>>cmd /c net use y: /del
>
>This is good. But, if I want to do it in one command, I might as well do this:
>
>c:\Windows\System32\cmd.exe /c net use y: \\1.1.1.1\d$ /y
>
>...where the last switch will simply send a Y to overwrite the already mapped drive.
>
>>2. In .Net you could check to see if the drive mapping exists e.g. use the DriveInfo class, if it doesn't throw an error trying to get info for Y: then it already exists
>
>That is also another interesting approach. However, the /y switch seems to be the simplest approach to resolve that issue so far.
Now I'm wondering if you even need CMD.EXE, since you're just executing Net.exe with parameters e.g.
%SystemRoot%\System32\net.exe use y: \\1.1.1.1\d$ /y
Regards. Al
"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov
Neither a despot, nor a doormat, be
Every app wants to be a database app when it grows up