|
From the News Page 11 | |
VBSFile.txt Debug script generator -- (a bit complex),
REM. To copy: Hold Ctrl, press A, press C.
Package.bat -- No other files than "N.GIF" is written.
Tested in Win98/XP.
Method: :<!--
batch code
goTo:! [or Exit].
-->HTML<!--
:! -->
Get input in all OS. -- Tested in DOS: Ver 6.22,
Win9X: 95X, 98, 98SE and ME,
WinNT: 2000/2K and WinXP but
isn't tested within other NT systems.
If %y% begins with a zero. Etc.
A better input routine and with caps option included.
TCPIP.VBS
DeskCpl.BAT and *.VBS Ask about 256 colors, (8, 16 or 32 bit).
(Put a link to this batch in your game folder).
VBSFile.txt -- The link is removed, (see the top of this page).
Free Space (Common comments in BAT and VBS).
Package.bat
Win9X/XP
:<!-- [ This BATch file is 69 lines, 3933 bytes. This line included ].
@echo off
if %winDir%.==. for %%C in (echo.Windows_isn't_running. goto) do %%C
%5 %0 move .htm exit "choice/tn,1" :: pause %OS% ~
if exist %0.bat %0.bat %1 %2 %3 %4 %5 %6 %7 %8
echo e0'GIF89a '0 20 0 B3 0 0 0 0 0 FF 0 0 FF CC 33 FF FF 00> N.GIF
echo e19 FF FF 99 FF FF CC FF FF FF F8 BF'$'0 0 0 0 0 0 0 00>> N.GIF
echo e2D 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0'!'F9 4 1 0 0 7 0 2C>> N.GIF
echo e46 0 0 0 0 ' '0 ' '0 40 4 8C F0 C8 'I'AB BD 'w'E8 1 F6>> N.GIF
echo e5A EE 9C A7 81 1A'%%'8A 40 AA AE E4'i'9E 1E B 'o'D8 31>> N.GIF
echo e6C B6 'sZZs'EF D3 92 1E'k8' AB FD'`'B5 CC 'q'90 9C ','>> N.GIF
echo e80 7F BC D3 'J'AA 'B'6 '}'C3'j'EF 9A CB'j'AD'6a`L'E E0>> N.GIF
echo e95"<"CA A7 AB'Y)'B2 9B EE F7 8B F3 A5 EB'v'C9 91 3A C4>> N.GIF
echo eA8'L'E7 F4 3E'm(1'84 1F'k\{['88']2'81'aB'5E 8E'X'5E'w'>> N.GIF
echo eC0'V'93 94 8A 8F'Td'0 9C'gx'8B'(ef'99's'89'hF'A7'}oOr'>> N.GIF
for %%C in ("eD9 AE'l'11 0 0';'" rCX df w00 q) do echo %%%8C>> N.GIF
type N.GIF|debug N.GIF
if %7==%OS% %1 "%~f0" "%~f0%2"&"%~f0%2"&cls&%6&%1 "%~f0%2" "%~f0"&%3
for %%C in ("%1 %0 %0%2" "start %0%2" %4 "%1 %0%2 %0" cls %3) do %%C
--><HTML><BODY BgColor="#000000"><style>P{Color:#C0C0C0;};</style>
<script language="JavaScript">function convert(){input=(document.
formcon.Input.value); origin=(document.formcon.Origin.value); dest=(
document.formcon.Destination.value);
base="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; c=0; Result="";for(t=1;
t<=input.length; t++){b=base.indexOf(input.substring(t-1,t).
toUpperCase()); n=b*(Math.pow(origin, input.length-t)); c+=n} a=100;
while (c< Math.pow (dest,a)) { a--; } while (a>-1){e=Math.pow (dest,
a); a--; d=((c-(c%e))/e) +1; c=c%e; Ciffer=base.substring (d -1, d);
Result= Result +Ciffer} document.formcon.output.value=Result}
</script>
<table width="500" align="center" border="16" cellpadding="16">
<tr bgcolor="#A0A0A0"><td><font face="verdana" size="2">
<form name="formcon"><p align="center"><br><u><font color="red"> Tips:
Jump with use of your [TAB] key.</font></u></p><br><input type="text"
name="Input" size="16"> Number to convert<br><input type="text"
name="Origin" size="3"> Original scale, ex. 16 for hex, 10 for dec, 2
for bin, etc.<br><input type="text" name="Destination"
size="3"> Destination scale<br><input type="button" onClick="convert(
this.form.Input.value,this.form.Origin.value,this.form.Destination.
value)" value="Calculate!"><br><input type="text" name="output" size=
"16"> Result of Conversion.<p align=right><a
href="http://2dos.homepage.dk/batutil/help/INDEX.HTM#upd"> <img
src="N.GIF" border=0 width=32 height=32> </a></form></font></td></tr>
</table>
<FORM NAME="Form1">
<INPUT TYPE="Button" NAME="Button1" VALUE="Click">
<SCRIPT FOR="Button1" EVENT="onClick" LANGUAGE="VBScript">
msgBox"Executed 4 in ONE: BATch, HTML, JS and VBScript.",64</SCRIPT>
</FORM>
<hr><p> Additional information about packages.
<h3><p>For testing the below script, copy and paste into FileName.WSF:
</h3><p><package><br><job id="Job1">
<br><script language="JScript">
<br>function jsSort(arr) {return arr.toArray().sort().join('\t')}
<br></script><br><script language="VBScript">
<br>dim arr: arr= array("Hi", "hi", "Testing,
Batch", "B", "A")<br>EchoArray "Not
sorted array:"<br>arr= split(jsSort(arr),vbTAB)<br>EchoArray
"Sorted array:"<br>sub EchoArray(V1)<br>wScript.echo vbCrLf
& V1<br>for i = 0 to uBound(arr): msgBox i & ": "
& arr(i) :next<br>end sub<br></script><br></job>
<br></package><p align="center"><font style="font-size=7in;
color=yellow">?<br>¿<img src="N.GIF" width=888 height=555></font>
</BODY></HTML>
|
Notes/etc.
Benny Pedersen,
BTW. FOR LOOP's compatibility solution for Win95/98/ME/NT/XP...,
While I developed the new technique at this page, I then figured
out an idea, namely: How to let a FOR LOOP works in both OS. The
loop parameter in WinNT often requires a tilde ~, but not Win9X,
Solution:
@If (%1)==() %0 %OS% ~
@Echo off
For %%i in ([Common to both OS]) do Echo %%%2i
If %1==%OS% Echo. [WinNT Stuff] & goTo:Next
Echo. [Win9X Stuff]
:Next
Links:
The UseNet
|
Input.bat
Win9X/NT/...
@ echo off
set Y=::
for %%C in (cls echo) do %%C:
if Windows_NT==%OS% set Y=IF,
%Y% NT4 == NT4 VER |Find "NT">NUL
%Y% ErrorLevel=1 %[ 2K,XP]%Color 1f&SET Y=&SET/PY= Input: &goTo %OS%
%Y% %Y%==%Y% set Y=FIND
echo Input:%[ Next line is 83 characters long: ]%
if FIND==%Y% for /f "tokens=*" %%a in ('format/f:160 a: ^|%Y% ".."')
::WinNT 4.0; PUT THIS AT THE END OF THE ABOVE LINE: do set Y=%%a
set Y=%Y:~30%&goTo %OS%
set Y=e102%[ DOS6.22 ]%
echo EXIT|%comspec%>nul/kPrompt fb800:140La0' '1f$_q|debug%[ Blue ]%
VER | Find "DOS">NUL
if errorlevel 1 set Y=e103%[ Win95/98/98SE/ME ]%
FC/N/LB1 NUL CON | FIND "1">%TMP%.\$.BAT
ECHO EXIT|%COMSPEC%/kPROMPT %Y%'SET Y='$_W$_Q|DEBUG %TMP%.\$.BAT>NUL
FOR %%C IN (CAL DE GOTO:Windows_) DO %%CL %TMP%.\$.BAT
: Windows_NT DOS(6.22) Win(95X,98,98SE,ME) NT(XP) NT(2000/2K) NT(4.0).
echo.
echo. [Y] = [%Y%]
set Y=
@ for %%c in (echo. pause cls) do %%c
|
Links:
|
If %y% begins with a zero, then Nothing
else; set y=0%y%
@echo off
set y= ?
for %%0 in (%%) do set y=%%%y%
for %%%% in (0) do set y=%%%y%
echo [y] = [%y%]
set y=
Benny Pedersen,
BTW. tested in Win98,
PS. Line num 13 is wrapped:
@echo off
if not ()==(%1) goTo 1_Sub.
mode con cols=40 lines=50
echo.EXIT|%comspec%>nul/kPrompt fb800:0Lfa0' '70$_q|debug%[ Colors ]%
::Input routine, Set Y:
echo.Input your first name as lowercase:
FC/N/LB1 NUL CON | FIND "1">%TMP%.\$.BAT
ECHO.EXIT|%COMSPEC%/kPROMPT e102'SET Y='$_W$_Q|DEBUG %TMP%.\$.BAT>NUL
FOR %%C IN (CAL DE) DO %%CL %TMP%.\$.BAT
::Routine using ONLY Command.COM for converting your value of Y:
for %%# in (a b c d e f g h i j k l m n o p q r s t u v w x y z) do call %
0 %%#,%y%
for %%%% in (" ") do set y=%y%
echo.
echo First name, uppercase %%Y%% is: %Y%
for %%v in (y old stop) do set %%v=
::Restart batch file, repeating your test:
for %%c in (echo echo.Ctrl+Break_or pause %0) do %%c:
: 1_Sub
%stop% for %%%1 in (/%1) do set y=%%%2%
%stop% set old=%y%
%stop% for %%"/" in (" ") do set y=%%%y%
%stop% if not %y%==%%%old% set stop= ::,
You can substitute the above "mode con cols=40 lines=50" with CLS instead.
3 different solutions using FOR %%%% technique,
1: Prefix a zero if it's not already prefixed
2: Cap the first letter
3: Remove prefixed zero(s)
We have used this technique in the past but the
solutions made at that time included Choice.com
etc... What's new here is that we can now do it
with ONLY internal %ComSpec% implemented stuff.
Here's my solution for numb 3 above. It removes
prefix of something, ex. zero(s).
Btw.
It allows both Y=Nothing and Y = S p a c e (s),
@echo off
set y=00000 000 0123
for %%y in (0%y%) do set y=%%%%y
: 1thLoop
set x=%y%
for %%0 in (%%) do set y=%y%
if not %x%==%y% goto 1thLoop
for %%%% in (" ") do set y=%%%y%
echo.%y%
set x=
set y=
CALL it within another batch file or just double click it.
BTW. Use /nocap for normal input and /cap switch for caps:
::Usage: CALL thisFile tempFile.bat variable /nocap /nocolor prompt
@ echo off
if .goto:==.%1 %1%2 EOF
if . == .%1 %0 %tmp%.\$.bat TEST_Var /cap /color Input your name:
%comSpec% /c%0 goto: echo. %1 %2 %3 %4 %5 %6 %7 %8 %9
echo prompt %prompt%>>%1
for %%c in (caL de) do %%cL %1
if TEST_Var==%2 echo. [TEST_Var] = [%TEST_Var%]
if TEST_Var==%2 for %%c in (pause cls set) do %%c %2=
goto EOF
: echo. Label for bad OS such as WinNT/XP. Not able to run most batch.
: echo Label for older and better OS such as Win98.
for %%c in (1 2) do shift
if /nocolor==%4 goto nocolor
for %%c in (cls %0) do %%c
%0:exit|%comspec% /kprompt fb800:140La0' '1f$_q|debug>nul
: nocolor
%0%5 %6 %7 %8 %9
if not %OS%.==. set /p%2=
if not %OS%.==. %ComSpec% /C%0%%1 %%0 :: 1: %%%2%%>%1
if not %OS%.==. goto continue
fc /n/Lb1 nul con|find "1">%1
prompt %%1 %%0 ::
ctty nul
%comSpec%/c%1|find "1">%1
ctty con
: continue
for %%c in (:: set :#) do %0%%c prompt=>>%1
%0shift>>%1
if /nocap.==%3. %0prompt %%prompt%% %%2>>%1
if /nocap.==%3. goto common
%0for %%%%a in (A) do set %2=%%%%%%2>>%1
%0for %%%%b in (B) do set %2=%%%2%%>>%1
%0for %%%%c in (C) do set %2=%%%2%%>>%1
%0for %%%%d in (D) do set %2=%%%2%%>>%1
%0for %%%%e in (E) do set %2=%%%2%%>>%1
%0for %%%%f in (F) do set %2=%%%2%%>>%1
%0for %%%%g in (G) do set %2=%%%2%%>>%1
%0for %%%%h in (H) do set %2=%%%2%%>>%1
%0for %%%%i in (I) do set %2=%%%2%%>>%1
%0for %%%%j in (J) do set %2=%%%2%%>>%1
%0for %%%%k in (K) do set %2=%%%2%%>>%1
%0for %%%%l in (L) do set %2=%%%2%%>>%1
%0for %%%%m in (M) do set %2=%%%2%%>>%1
%0for %%%%n in (N) do set %2=%%%2%%>>%1
%0for %%%%o in (O) do set %2=%%%2%%>>%1
%0for %%%%p in (P) do set %2=%%%2%%>>%1
%0for %%%%q in (Q) do set %2=%%%2%%>>%1
%0for %%%%r in (R) do set %2=%%%2%%>>%1
%0for %%%%s in (S) do set %2=%%%2%%>>%1
%0for %%%%t in (T) do set %2=%%%2%%>>%1
%0for %%%%u in (U) do set %2=%%%2%%>>%1
%0for %%%%v in (V) do set %2=%%%2%%>>%1
%0for %%%%w in (W) do set %2=%%%2%%>>%1
%0for %%%%x in (X) do set %2=%%%2%%>>%1
%0for %%%%y in (Y) do set %2=%%%2%%>>%1
%0for %%%%z in (Z) do set %2=%%%2%%>>%1
if not %OS%.==. for %%c in ("%%%2%%|find "%%%%">nul") do %0 %0%%~c>>%1
set CMDLINE=%comspec%/kprompt
if %OS%.==. %0:exit|%CMDLINE% %0%%%%%2%%%%$bfind "%%%%%%%%"$gnul$_>>%1
set CMDLINE=
%0>>%1
%0if errorlevel 1 prompt %%prompt%% %%%2%%>>%1
%0if not errorlevel 1 prompt %%prompt%% %%2>>%1
: common
%0if not %%3.==. goto #>>%1
%0set %2=%%prompt%%>>%1
: EOF
:: Detecting availability of drive specifications, C...Z.
:: If Start /Wait /Min instead of CALL, then remove the last two Rem:
@%1 echo off
rem>%tmp%.\~.tmp
for %%# in (C D E F G H I J ) do CALL %0 goto:# %%# errorlevel
for %%C in (cls echo%DR%: type del :exit) do %%C %tmp%.\~.tmp
:#
for %%C in (Rem:ECHO:OFF CLS %2: C:) do %%C
echo.:exit|%comspec% /kprompt db800:0L2$_q|debug|find " .">nul
for %%B in (True False) do if not %3 %%B105 echo.%2: %%B>>%tmp%.\~.tmp
::for %%B in (False True) do if not %3 %%B105 set DR=%DR%.%%B
Rem:CLS
' You can choose another word than True for Errorlevel 0. Just use
' a formula based on the below ex; TRUE in reversed order is EURT:
' a=
' SUM( 10^3 ( ASCII(E) -48 )
' 10^4 ( ASCII(U) -48 )
' 10^5 ( ASCII(R) -48 )
' 10^6 ( ASCII(T) -48 )
' ).
' X = 256 int(a/256) -a +256 +1
' or use EURT.VBS (it don't write anything to disk; it just pop up
' a Copy/Paste Box which can be used for grapping the batch code):
dim exp0, a, x
exp0= inputBox("Input exp0:", "If ErrorLevel 0 [Zero].", "True")
if "" = exp0 then wScript.quit
for i = 3 to 7: a= a+10^i *(asc(mid(strReverse(right(exp0,5)) &_
"00000", i-2, 1)) -48): next: x= 256 * int(a/256) -a +512 +1
while x< 100: x= x +256: wend: while x> 355: x= x -256: wend
inputBox "Copy/Paste Box:", x, "@ echo off" & vbCrLf & vbCrLf &_
"for %%B in (exp1 " & exp0 & ") do if not errorlevel %%B" & x &_
" set var=%%B" & vbCrLf & "echo.%var%." & vbCrLf & "set var=" &_
vbCrLf & vbCrLf & "ctty nul" & vbCrLf &_
"for %%B in (" & exp0 & " exp1) do if not errorlevel %%B" & x &_
" echo %%B>>con" & vbCrLf & "ctty con"' EOF
' Right click and grap the text. BTW. exp1 can be almost whatever.
' PS.: You can make Errorlevel 0 or 1 with use of one of this two:
' 0: echo|find "E">nul
' 1: echo|find "">nul
' TCPIP.VBS
dim obj, Rfile,R, T,LT, key,var,CurrentVal, SuggestVal, input, Wfile
set obj= CreateObject("WScript.Shell")
if "%OS%" = obj.ExpandEnvironmentStrings("%OS%") then
key= "HKLM\System\CurrentControlSet\Services\VxD\MSTCP\"
var= "DefaultRcvWindow": CurrentVal= 1024*08 -1
else key= "HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\"
var= "TcpWindowSize": CurrentVal= 1024*16 -1
end if: on error resume next: CurrentVal= obj.RegRead(key & var)
input= inputBox("Input an URL:", "ISP", "updates.pandasoftware.com")
if input="" then set obj= Nothing: wScript.quit
obj.Run "%ComSpec% /C Tracert " & input & ">""%tmp%.\~isp.tmp""",0,1
set Rfile= CreateObject("Scripting.FileSystemObject").OpenTextFile _
(obj.ExpandEnvironmentStrings("%tmp%") & "\~isp.tmp",1)
T= 000: LT= T : ReadFile : Rfile.close
sub ReadFile
do until EOF: R= Rfile.ReadLine: on error resume next
if isNumeric(mid(R,3,1))Then for i=7 to 25 step 9_
: LT= cInt(mid(R,i,3)): T= cInt(T+(LT>T)*T-(LT>T)*LT): next
on error goTo 0
loop
end sub: LT="Low" : SuggestVal=1024*16 -1 ' ...100 ms
if T>100 then LT="Normal": SuggestVal=1024*32 -1 '101...200 ms
if T>200 then LT="High" : SuggestVal=1024*64 -1 '201... ms
if CurrentVal=SuggestVal then SuggestVal="No modification is needed"
input= inputBox("The current value of the variable " & var & " is "_
& CurrentVal & " kb." & vbCrLF & vbCrLF _
& "Regards the result of Tracert URL:" & vbCrLF &""""& input& ""","_
& vbCrLF& "a suggested value below is based of the measured time: "_
& T & " ms (" & LT & ")." & vbCrLF & vbCrLF & "Press [OK] for "_
& "using this value, or input the letter D in any case for using " _
& "the default system value:", "TCP/IP Settings.", SuggestVal)
if isNumeric(input) and input<>"" then if input +0=SuggestVal then _
obj.RegWrite key & var, SuggestVal, "REG_DWORD"
if uCase(input) = "D" then obj.RegDelete key & var: on error goTo 0
set Wfile= CreateObject("Scripting.FileSystemObject").OpenTextFile _
(obj.SpecialFolders("Startup") & "\~isp.vbs",2,-1)
Wfile.WriteLine "dim obj: set obj=CreateObject(""WScript.Shell"")" _
&vbCrLf&"obj.run""%comSpec% /Cdel """"%tmp%"&"\~isp.tmp"""""",0,1:"_
& "obj.run ""%comSpec% /Cdel """"" & obj.SpecialFolders("Startup") _
& "\~isp.vbs"""""",0" & vbCrLf & "set obj= Nothing": Wfile.close
set obj= Nothing: set Rfile= obj: set Wfile= obj
:: Ex. A ShortCut: %WINDIR%\DESKTOP\DESKCPL.BAT %WINDIR%\NOTEPAD.EXE A 16
:: Would be running DeskCpl (A for Ask) and finally use 16 bit color.
:: DeskCpl.BAT can be used without any parameters, ofcause.
@echo off
If NOT %1.==Minimized. Start /M %0 Minimized %1 %2 %3
If NOT %1.==Minimized. GoTo:EOF
If %2.==ECHO.. GoTo Write
If Exist "%tmp%.\DeskCpl.vbs" GoTo Run
If %OS%.==Windows_NT. GoTo:EOF
%ComSpec% /C%0 Minimized ECHO.> "%tmp%.\DeskCpl.vbs"
:Run
%ComSpec% /cREM
CScript.exe //NoLogo "%tmp%.\DeskCpl.vbs" %3
:Wait
If errorlevel 88 GoTo Next
If not errorlevel 44 GoTo Wait
:Next
If errorlevel 89 GoTo:EOF
If NOT exist %2 GoTo:EOF GoTo:EOF
Start /Wait /Max %2
CScript.exe //NoLogo "%tmp%.\DeskCpl.vbs" %4
GoTo:EOF
:Write
%2 Dim TitleDeskCpl: TitleDeskCpl= "Properties"
%2 Dim Bit24Option: Bit24Option= False
%2 Dim TestMode: TestMode= True
%2
%2 Dim Key,Arg,WshShell: Set WshShell= CreateObject("WScript.Shell")
%2 On Error Resume Next: Arg= WScript.Arguments(0): On error GoTo 0'
%2 If NOT WScript.Arguments.Count=0 AND NOT UCase(Arg)="A" Then
%2 Key= WScript.Arguments(0)' Rem Use q for quit and a for ask.
%2 Else Dim Default: Default= 256.
%2 For Each Arg in Array (16,24,32)
%2 If CreateObject("Scripting.FileSystemObject")._
%2 FileExists(WshShell.ExpandEnvironmentStrings _
%2 ("%TMP%") + ".\__" + CStr(Arg) + ".tmp")_
%2 Then Default= Arg
%2 Next
%2 If Bit24Option Then
%2 Key= InputBox("8, 16, 24 or 32 bit?", "Colors",Default)
%2 Else Key= InputBox("8, 16 or 32 bit?", "Colors",Default)
%2 End If
%2 End If: On Error Resume Next: Key= CInt(Key +(Key="256")*248)
%2 On Error GoTo 0'
%2 WshShell.Run"%ComSpec% /cDEL ""%tmp%.\__*.tmp""", 0, -1'
%2 For Each Arg in Array (8,16,24,32)
%2 If Key=Arg Then Dim Continue: Continue=True: Exit For
%2 Next:If NOT Continue Then WScriptEnd 88,NoMsg
%2 Dim oExec: Set oExec= _
%2 WshShell.Exec("Rundll32.exe Shell32.dll,Control_RunDLL Desk.cpl")
%2 WshShell.Run"%ComSpec% /cREM>""%tmp%.\__"+CStr(WshShell.RegRead _
%2 ("HKLM\Config\0001\Display\Settings\BitsPerPixel"))+ ".tmp""", 0.
%2 Key= "{UP " + CStr(4-(Key/8) +(Bit24Option=0)*(1+(Key=32))) + "}"
%2 If NOT TestMode Then Key= Key + "~"
%2 Do Until WshShell.AppActivate(TitleDeskCpl)
%2 If StartTime = "" Then Dim StartTime: StartTime= Timer
::%2 If Left(Timer-StartTime, 1)="4" Then WScriptEnd 89,"Timeout"
Prompt $ If Timer-StartTime$G4 Then WScriptEnd 89,"Timeout"
echo on
% %
@echo off
%2 Loop
%2 WshShell.sendKeys"+{TAB}{UP}{RIGHT 7}{TAB 1}{DOWN 4}" + Key
%2 Do While oExec.status=0: WScript.sleep 99: Loop: WScriptEnd 44,""
%2 Sub WScriptEnd(Level,Msg)
%2 If not Msg="" Then MsgBox"The title above the window of """_
%2 + "Display Properties"" was not expected." + vbCrLf _
%2 + "The current setting of the variable named TitleDeskCpl "_
%2 + "is " + CStr(TitleDeskCpl) + vbCrLf + vbCrLf + "Solution"_
%2 + ": Open this program file in for ex. ""Notepad"". Modify"_
%2 + " one of the first three lines." + vbCrLf + "The correct"_
%2 + " setting maybe ""Display"" or/and ""Properties"" but it"_
%2 + " must be written in your language.",64,"(title TITLE).":_
%2 WshShell.Run"%WinDir%\Notepad "+CStr(WScript.ScriptFullName)
%2 Set oExec= Nothing: Set WshShell= oExec: WScript.quit(Level)
%2 End Sub' Benny Pedersen, http://2dos.homepage.dk/
:EOF
Free Space
::' Both the :'Comment (or Label) and the ::'Comment is valid
::' syntax in both DOS Batch files (BAT) and for WSH (VBS)...
:'FreeSpace.BAT
@ Echo off
@ If NOT exist "%0" "%0.bat"
@ Find /v "@ "< %0 >"%TMP%.\FreeSpace.vbs"
@ WScript.exe "%TMP%.\FreeSpace.vbs" "Delete your self."
@ Cls
@ GoTo:'EOF
Dim Drive, fso, FreeSpaceB, FreeSpaceK, FreeSpaceM, FreeSpaceG
Drive= UCase("c:")
Set fso= CreateObject("Scripting.FileSystemObject")
FreeSpaceB= FormatNumber(fso.getDrive(Drive).freeSpace/2^00,0)
FreeSpaceK= FormatNumber(fso.getDrive(Drive).freeSpace/2^10,0)
FreeSpaceM= FormatNumber(fso.getDrive(Drive).freeSpace/2^20,0)
FreeSpaceG= FormatNumber(fso.getDrive(Drive).freeSpace/2^30,0)
MsgBox "Free Space: " & vbTab & vbTab & vbCrLf & vbCrLf _
& "Bytes: " & vbTab & FreeSpaceB & vbCrLf _
& "Kbytes:" & vbTab & FreeSpaceK & vbCrLf _
& "Mbytes:" & vbTab & FreeSpaceM & vbCrLf _
& "Gbytes:" & vbTab & FreeSpaceG _
, 64, fso.getDrive(Drive).volumeName & " (" & Drive & ")"
Set fso= Nothing
If WScript.Arguments.count >0 Then
Show= Abs(False): Wait= False
CreateObject("WScript.Shell").Run "%ComSpec% /c Del """ _
& WScript.ScriptFullName & """", Show, Wait
End If
: 'EOF
::' Benny Pedersen, http://2dos.homepage.dk
::' PS. Kbytes isn't (bytes/1000) but bytes/1024 = bytes/2^10
TMP or TEMP and WSH (JScript, VBS files and...)
:' A running 'MS Script Ducumentation' will use the environment variable
:' named TMP, not TEMP! So if your tmporary stuff goes to the RAM drive;
:' (ex. a 32 MB virtual disk), then the WSH ducumentation "SCRIPT56.CHM"
:' won't work. Solution:
@ ECHO OFF%[ ********** WSH_DOC.BAT (Win98) ********** ]%
SET TMP=%WINDIR%\TEMP
START "C:\Program Files\MICROS~1\SCRIPT~1\SCRIPT56.CHM"
|