Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> re: Script examples for NT. (yuk!)

re: Script examples for NT. (yuk!)

From: Eric D. Pierce <PierceED_at_csus.edu>
Date: Wed, 30 May 2001 09:51:20 -0700
Message-ID: <F001.00313B87.20010530090644@fatcity.com>

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 <WINNT-L_at_PEACH.EASE.LSOFT.COM> ]

> -----Original Message-----
> From: Andrew S. Baker [mailto:ListMember_at_UltraTech-llc.com]
> Sent: Tuesday, May 29, 2001 8:46 PM
> To: glenzer_at_cpl.org
> Cc: WINNT-L_at_PEACH.EASE.LSOFT.COM
> 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
> ==============================================================

"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 ==========

http://www.ultratech-llc.com/KB/?File=!Contents.TXT

...

SCRIPTING & AUTOMATION

...
(end)

-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: Eric D. Pierce
  INET: PierceED_at_csus.edu

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: ListGuru_at_fatcity.com (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).
Received on Wed May 30 2001 - 11:51:20 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US