You just outlined the unspoken requirement that I had asked about.
if exist x:\ (
net use x:|find /i "\\server\share <file:///\\server\share> "
if errorlevel 1 (
net use x: /d /y >nul 2>&1
net use x: \\server\share <file:///\\server\share> )
) else (
net use x: \\server\share
)
Why not just net use x: /d and net use x: \\server\share
<file:///\\server\share> unconditionally? Because if there are open files
on the drive letter then they will be closed, possibly with unwanted
side-effects. We don't know when this script will be running.
From: Steve Kelsay [mailto:[email protected]]
Sent: Friday, March 20, 2009 2:02 PM
To: NT System Admin Issues
Subject: RE: Scrip Help please?
I can map a drive, and unmap it. What I need to know is how I can retrieve
the share to which the existing drive is mapped, so for example, if I want
the w: drive to map to \\vmdorscnimg\vdeplus <file:///\\vmdorscnimg\vdeplus>
, I can check to see if the W: drive is already mapped, and if it is not
mapped to the desired W: mapping, then execute the remapping of it.
So far, I can do everything except see where the existing drive is mapped TO
so that I can them do a comparison.
From: Michael B. Smith [mailto:[email protected]]
Sent: Friday, March 20, 2009 12:38 PM
To: NT System Admin Issues
Subject: RE: Scrip Help please?
In fact, call me lazy, but I just short-cut this process, this way:
Net use x: /del 2>nul >nul
Net use x: \\server\share
From: Carl Houseman [mailto:[email protected]]
Sent: Friday, March 20, 2009 12:33 PM
To: NT System Admin Issues
Subject: RE: Scrip Help please?
What is done with the mapping that is retrieved? Output to the screen,
something else?
What you've specified so far doesn't need VBS, can be done in fewer lines of
simple .cmd/.bat scripting.
if exist x:\ (
net use x:|find /I "remote name"
) else (
net use x: \\server\share
)
Doesn't get much simpler.
Carl
From: Steve Kelsay [mailto:[email protected]]
Sent: Friday, March 20, 2009 12:19 PM
To: NT System Admin Issues
Subject: Scrip Help please?
I am looking for help writing a VBScript to
1. Detect whether a specified mapped drive exists
2. If so, retrieve the target mapping (if the X: drive is not mapped
to \\server\shar <file:///\\server\share> e, then map it )
I have Googled and found lots of stuff, but nothing that does this. I can
retrieve the drive letter and see if it exists, but where it is mapped to is
eluding me.
It has to be simple.
~ Finally, powerful endpoint security that ISN'T a resource hog! ~
~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/> ~