http://www.ultratech-llc.com/KB/Scripts/?File=Scripting.BAT
(also see bottom of this message for more URLs)
http://www.ultratech-llc.com/KB/?File=!Contents.TXT
----------forwarded message follows----------
[Date sent: Wed, 30 May 2001 10:32:11 -0400
To: Recipients of WINNT-L digests <[EMAIL PROTECTED]> ]
> -----Original Message-----
> From: Andrew S. Baker [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, May 29, 2001 8:46 PM
> To: [EMAIL PROTECTED]
> Cc: [EMAIL PROTECTED]
> Subject: RE: Yet another scripting question
>
>
> >>However, if the user double clicks the
> >>script again, it should not map a new
> >>drive, it will only open an Explorer
> >>window showing them the contents of
> >>the already mapped drive.
>
> That will actually require a bit more code than you've used so far,
> since the ENV variables will not retain enough info between runs.
>
> Here's a script using the CD command, which I don't like (for this
> purpose). Rule #3 in scripting should be to always use the FOR
> command... :)
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> @ECHO OFF
> SETLOCAL
> SET DRIVELIST=z y x w v u t s r q p o n m l k j i h g f e d
> SET CHECKDRIVE=FALSE
> FOR %%D IN (%DRIVELIST%) DO CALL :CheckDrive %%D
> ECHO %CHECKDRIVE%
> ENDLOCAL
> GOTO :EOF
>
> :CheckDrive
> rem - %1 = Current Drive Letter
> CD %1:\ 2>NUL
> IF %ERRORLEVEL% EQU 1 IF /I "%CHOSEN%"=="FALSE" SET CHECKDRIVE=%1:
> GOTO :EOF
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
>
> As a replacement for CD, I chose PUSHD, especially since it already
> does the first part of what you want (chosing the highest available
> drive letter).
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> @ECHO OFF
> SETLOCAL
> SET RESOURCE=\\COMPUTER\SHARE
> SET CHECKDRIVE=NOT SET
> PUSHD %RESOURCE%
> IF %ERRORLEVEL% EQU 0 FOR /F "DELIMS=\" %%D IN ('CD') DO SET
> CHECKDRIVE=%%D
> ECHO %CHECKDRIVE%
> POPD
> ENDLOCAL
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
>
>
> Now, if you don't want the drive assigned again, you should check
for
> the existence of the mapping before running the rest of the
script....
>
>
> See the following:
> http://www.ultratech-llc.com/KB/Scripts/?File=MapDrive.BAT
>
> The full script will be here at some point before tomorrow
morning...
>
>
>
> ==============================================================
> ASB - http://www.ultratech-llc.com/KB/?File=Troubleshoot.TXT
> ==============================================================
------- Forwarded message follows -------
Date sent: Wed, 30 May 2001 01:38:54 -0700
"Andrew S. Baker" wrote:
> I ended up using PUSHD, since it is native to NT/2000 and does all the
> work of choosing the highest free drive.
>
==========begin file c:\CMD\TEST\freedrive.cmd ==========
001. @echo off
002. setlocal
003. set tgt=%1
004. if /i "%tgt%" NEQ "HIGHEST" if /i "%tgt%" NEQ "LOWEST" (
005. echo.
006. echo Specify an argument of HIGHEST to return the highest free drive letter
007. echo Specify an argument of LOWEST to return the lowest free drive letter
008. endlocal&goto :EOF
009. )
010. set free_drives=
011. for %%a in (
012. z y x w v u t s r q p o n m l k j i h g f e d c b
013. ) do call :test %%a
014. set free_drives=%free_drives:~1%
015. call :%tgt%
016. endlocal&set %~n0=%free_drive%&goto :EOF
017.
018. :test
019. if exist %1: goto :EOF
020. set free_drives=%free_drives% %1:
021. goto :EOF
022.
023. :lowest
024. for /f "tokens=1 delims=: " %%a in (
025. "%free_drives%"
026. ) do set free_drive=%%a:
027. goto :EOF
028.
029. :highest
030. call :length %free_drives%
031. set /a pos = length - 3
032. call :exec set free_drive=%%free_drives:~%pos%,2%%%
033. goto :EOF
034.
035. :length
036. set S1=%*
037. set length=0
038. :lloop
039. if not defined S1 goto :EOF
040. set S1=%S1:~1%
041. set /a length+=1
042. goto :lloop
043.
044. :exec
045. %*
046. goto :EOF
==========end file c:\CMD\TEST\freedrive.cmd ==========
------- End of forwarded message -------
http://www.ultratech-llc.com/KB/?File=!Contents.TXT
...
SCRIPTING & AUTOMATION
* http://www.ultratech-llc.com/KB/?File=Assoc.TXT
* http://www.ultratech-llc.com/KB/?File=Audit.TXT
* http://www.ultratech-llc.com/KB/?File=AutoLogon.TXT
* http://www.ultratech-llc.com/KB/?File=BatchJob.TXT
* http://www.ultratech-llc.com/KB/?File=Browser.TXT
* http://www.ultratech-llc.com/KB/?File=CopyPerms.TXT
* http://www.ultratech-llc.com/KB/?File=DateTime.TXT
* http://www.ultratech-llc.com/KB/?File=Delegate.TXT
* http://www.ultratech-llc.com/KB/?File=DelOld.TXT
* http://www.ultratech-llc.com/KB/?File=EnvVars.TXT
* http://www.ultratech-llc.com/KB/?File=ERD.TXT
* http://www.ultratech-llc.com/KB/?File=InUse.TXT
* http://www.ultratech-llc.com/KB/?File=License.TXT
* http://www.ultratech-llc.com/KB/?File=Monitoring.TXT
* http://www.ultratech-llc.com/KB/?File=NetShell.TXT
* http://www.ultratech-llc.com/KB/?File=NTRights.TXT
* http://www.ultratech-llc.com/KB/?File=NTVer.TXT
* http://www.ultratech-llc.com/KB/?File=OSType.TXT
* http://www.ultratech-llc.com/KB/?File=Perms.TXT
* http://www.ultratech-llc.com/KB/?File=Processes.TXT
* http://www.ultratech-llc.com/KB/?File=QuoteMarks.TXT
* http://www.ultratech-llc.com/KB/?File=Reserved.TXT
* http://www.ultratech-llc.com/KB/?File=ResKit.TXT
* http://www.ultratech-llc.com/KB/?File=RestartIIS.TXT
* http://www.ultratech-llc.com/KB/?File=Scheduler.TXT
* http://www.ultratech-llc.com/KB/?File=Scripting.TXT
* http://www.ultratech-llc.com/KB/?File=Services.TXT
* http://www.ultratech-llc.com/KB/?File=SetPerms.TXT
* http://www.ultratech-llc.com/KB/?File=SID.TXT
* http://www.ultratech-llc.com/KB/?File=TaskSched.TXT
* http://www.ultratech-llc.com/KB/?File=Uptime.TXT
* http://www.ultratech-llc.com/KB/?File=Versions.TXT
...
(end)
--
Please see the official ORACLE-L FAQ: http://www.orafaq.com
--
Author: Eric D. Pierce
INET: [EMAIL PROTECTED]
Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051
San Diego, California -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from). You may
also send the HELP command for other information (like subscribing).