Hello

Adam Peart wrote:

At 01:09 PM 1/31/2005, you wrote:

-----8<---------------------------------
@echo off
setlocal

cd /d %0\..

if errorlevel 1 (
 net use /PERSISTENT:NO > NUL:
 net use Z: \\ntinstall\install > NUL:
 cd /d Z:\
 set connect=YES
)

In dos, you can only work through a drive letter. You can't directly use a unc path.

Yes and no, you can start a script with \\ntinstall\intall\test.cmd from eg. C:\winnt\ (or double click through browsing from the Windows Explorer to this share), but you can not cd into a UNC path.

But in my example the cd /d %0\.. will fail (and should if %0
contains a UNC), and then sets errorlevel to 1, which is then
checked with the if loop and then the Z: drive is mappend and
ready for the scripts/paths called from the test.cmd to use.

But when the script is started from Z:\ drive the cd /d %0\..
will work and so the if loop will be skiped.

Probably it is a bad example with the text.cmd directly in the
root of Z:\ but should work. I did my testing on an other
drive/share in an folder.

Just save the script into a file an try it out (and change the X:
to Z: in the last net use line as corrected in the other mail),
nothing bad will happend, only some text output.

My script will give some error if the Z: is already mapped and
the script is started as \\ntinstall\install\test.cmd, as this is
not checkt. Probably a better solution would be to change the
first if loop of the script as following (not tested, as I'm
currently at home):

-----8<---------------------------------

if errorlevel 1 (
 net use /PERSISTENT:NO > NUL:
 net use Z: \\ntinstall\install > NUL:
 if errorlevel 0 (
  set connect=YES
 )
 cd /d Z:\
)

-----8<---------------------------------

This way, the Z: drive gets only disconnected at the end of the
script if it wasn't already connected at the start, the first
version did disconnect anyway if the script is started from the UNC.

This solution will fail, if the server is not reachable, but as
we start the script from the same server/share it should be
reachable and not be a big problem. ;)


bye Fabian




------------------------------------------------------- This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting Tool for open source databases. Create drag-&-drop reports. Save time by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc. Download a FREE copy at http://www.intelliview.com/go/osdn_nl _______________________________________________ unattended-info mailing list unattended-info@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/unattended-info

Reply via email to