Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Process class and DOS command
Message
From
24/02/2014 16:32:37
 
 
To
24/02/2014 16:20:03
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01595074
Message ID:
01595077
Views:
35
>I use the Process class to execute a DOS command.
>
>The command is like this:
>
>c:\Windows\System32\cmd.exe /c if not exist y: net use y: \\1.1.1.1\h$
>
>So, basically, if the y: drive does not exist, it will map it. This works well from the CMD window.
>
>But, if I try the same from a .NET application, I get this:
>
>y: has a remembered connection to \\1.1.1.1\f$. Do you
>want to overwrite the remembered connection? (Y/N) [Y]:
>
>So, basically, it seems from the .NET application, it does not recognize that y: already exists. So, it executes the command thus resulting in this output.
>
>Anyone would have an idea of what is going on here?

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

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
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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform