Δ Wednesday, June 30th 2010
bar1
   
    

Δ
Single Windows Progress Bar With Model Of Machine Logic
for each style refresh time fade function
 
How to create HTA progress bar, read in text messages into single window + model of computer logic

.... 
  

bar1
<script language="vbscript">
Window.ReSizeTo 0,0
Window.moveTo -500, 0
</script>

<!--
==============================================
Name: Progress Bar
Author: Eddie Jackson
Contact: mrnettek2000@yahoo.com
Created on: 06/28/2010
Modified:
Modified by:
Description: General use progress bar + Refresh + Read updating message from text file
==============================================
-->
<HTML>
<HEAD>
<TITLE>&nbsp;</TITLE>
<HTA:APPLICATION ID="Progress Bar"
BORDER="THIN"
INNERBORDER="YES"
SCROLL="NO"
CAPTION="YES"
SHOWINTASKBAR="NO"
SINGLEINSTANCE="YES"
SYSMENU="NO"
MAXIMIZEBUTTON="NO"
MINIMIZEBUTTON="NO"
CANCELBUTTON="NO"
CONTEXTMENU="NO"
WINDOWSTATE="NORMAL"

>
<STYLE> body {margin:2}
</STYLE>

<style>
body {
font-family:Verdana;
font-size: 12px;
color: black;
scrollbar-face-color:white;
scrollbar-arrow-color:black;
scrollbar-track-color:#D84419;
text-align:center;
background: lightgray;
}
#outer {
text-align:left;
border:1px solid #000000;
width:950px;
margin:auto;
}

#hdr {
height:80px;
background:white;
}

#bar {
height:25px;
background:#7B6E66;
color: #FFFFFF;
border:solid #000000;
border-width:1px 0 1px 0;
font-size: 12px;
font-weight: bold;
}

#bodyblock {
position:relative;
background: #cccccc;
color: #333333;
width:950px;
padding:0;
}

#l-col {
float:left;
background:#EDEBEA;
color: #D44519;
width:145px;
Height:400px;
}

#cont {
width:795px;
background:#ffffff;
color: #333333;
border:solid #000000;
border-width:0 0 0 1px;
text-align:left;
height:700px;
padding: 5px;
}

#ftr {
height:25px;
background:#c0c0c0;
color: #333333;
border:solid black;
border-width:1px 0 0 0;
margin:0;
}

table {
border-width: thin;
border-color: black;
border-style: groove;
font-size: 10px;
}

td {
border-width: 1px;
padding: 1px;
border-style: solid;
border-color: black;

}


</style>

</HEAD>

<body>

<SCRIPT Language="VBScript">
Dim varMODEL
Dim strComputer
Dim objWMIService
Dim colItems

Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20

strComputer = "."
On Error Resume Next
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM " & "Win32_ComputerSystem", "WQL", wbemFlagReturnImmediately + wbemFlagForwardOnly)

For Each objItem In colItems
'msgbox objItem.Model
varMODEL = Trim(objItem.Model)
Next





On error resume next
Sub Window_Onload
On error resume next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * From Win32_DesktopMonitor")

For Each objItem in colItems
intHorizontal = objItem.ScreenWidth
intVertical = objItem.ScreenHeight
Next
End Sub

sub launch(pgm)
On error resume next
set shell = createobject("wscript.shell")
shell.run pgm
end sub


Sub Window_OnLoad
On error resume next
w = 505
h = 101
Return = ResizeWindow(w, h)
Return = CenterWindow(w, h)

Dim timerID
timerID = window.setInterval("RefreshTime", 1000) 'milliseconds
RefreshTime
End Sub


Sub RefreshTime
on error resume next
'This reads in the progress message
ForReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("c:\drivers\scripts\zoom\msg.txt", ForReading)
strLine = objFile.ReadLine

if varMODEL = "Inspiron 1010" then
on error resume next
if strLine<>"Device is installed and ready to use!" then
'msgbox strLine
DataArea.InnerHTML = "<h6>"&strLine & "<br><br>"&"<IMG src="&chr(34)&"c:\drivers\scripts\zoom\progress.gif"&chr(34)&" application="&chr(34)&"yes"&chr(34)&" width="&chr(34)&"35%"&chr(34)&" height="&chr(34)&"35%"&chr(34)&" marginwidth="&chr(34)&"0"&chr(34)&" marginheight="&chr(34)&"0"&chr(34)&" frameborder="&chr(34)&"0"&chr(34)&"></IMG></h6>"
Else
DataArea.InnerHTML = "<h6><br>"&strLine&"</h6>"
end if

else

if strLine<>"Device is installed and ready to use!" then
on error resume next
'msgbox strLine
DataArea.InnerHTML = "<h5>"&strLine & "<br><br>"&"<IMG src="&chr(34)&"c:\drivers\scripts\zoom\progress.gif"&chr(34)&" application="&chr(34)&"yes"&chr(34)&" width="&chr(34)&"35%"&chr(34)&" height="&chr(34)&"35%"&chr(34)&" marginwidth="&chr(34)&"0"&chr(34)&" marginheight="&chr(34)&"0"&chr(34)&" frameborder="&chr(34)&"0"&chr(34)&"></IMG></h5>"
Else
DataArea.InnerHTML = "<h5><br>"&strLine&"</h5>"
end if
end if


objFile.Close
End Sub

Function ResizeWindow(w, h)
On error resume next
width = w
height = h
window.resizeTo width, height
End Function

Function CenterWindow(w, h)
On error resume next
x = (screen.width-w)/2
y = (screen.height-h)/2
window.moveTo x, y

End Function
</SCRIPT>


<script type="text/javascript">
window.onload = FadeFunction
var i = 0
function FadeFunction() {
if (i < 350) {
i=i+3
}
var d = document.body.style
d.filter = "alpha(Opacity="+i+")"
d.opacity = i/350
var num = document.all ? 5 : 350
setTimeout("FadeFunction()",num)
}

</script>

<center>
<span id=DataArea></span>

</center>
<br>
</br>
</BODY>
</HTML>
bar1

bar1

bar1    





Δ Monday, June 28th 2010
bar1
 
 
  
Δ
Countdown Boxes & Percent Complete Installations Shell
 
How to add countdown boxes and percentage complete to your progress bars

  

bar1
@echo off
title DIAGNOSTIC WINDOW

:PREPARE
@taskkill.exe /f /im mshta.exe
@taskkill /f /im wscript.exe
@taskkill /f /im rundll32.exe


ECHO Please unplug your USB YourDriverNameFolder at this time(5)>"C:\drivers\scripts\YourDriverNameFolder\msg.txt"
IF EXIST "C:\drivers\scripts\YourDriverNameFolder\progressbar1.hta" START "" "C:\drivers\scripts\YourDriverNameFolder\progressbar1.hta"
ping -n 2 127.0.0.1>nul
ECHO Please unplug your USB YourDriverNameFolder at this time(5)>"C:\drivers\scripts\YourDriverNameFolder\msg.txt"
ping -n 2 127.0.0.1>nul
ECHO Please unplug your USB YourDriverNameFolder at this time(4)>"C:\drivers\scripts\YourDriverNameFolder\msg.txt"
ping -n 2 127.0.0.1>nul
ECHO Please unplug your USB YourDriverNameFolder at this time(3)>"C:\drivers\scripts\YourDriverNameFolder\msg.txt"
ping -n 2 127.0.0.1>nul
ECHO Please unplug your USB YourDriverNameFolder at this time(2)>"C:\drivers\scripts\YourDriverNameFolder\msg.txt"
ping -n 2 127.0.0.1>nul
ECHO Please unplug your USB YourDriverNameFolder at this time(1)>"C:\drivers\scripts\YourDriverNameFolder\msg.txt"
ping -n 5 127.0.0.01>nul


ECHO Uninstalling Drivers...>"C:\drivers\scripts\YourDriverNameFolder\msg.txt"
:UNINSTALL
cls
echo Uninstalling drivers silent mode...
ECHO Uninstalling Drivers(0%%)>"C:\drivers\scripts\YourDriverNameFolder\msg.txt"
ECHO Uninstalling Drivers(0%%)>"C:\drivers\scripts\YourDriverNameFolder\msg.txt"
ping -n 2 127.0.0.1>nul
start /wait c:\drivers\DPInst.exe /u C:\drivers\usb\ftdibus.inf /s
ping -n 2 127.0.0.1>nul
ECHO Uninstalling Drivers(25%%)>"C:\drivers\scripts\YourDriverNameFolder\msg.txt"
start /wait c:\drivers\DPInst.exe /u C:\drivers\usb\ftdibus.inf /s
ping -n 2 127.0.0.1>nul
ECHO Uninstalling Drivers(50%%)>"C:\drivers\scripts\YourDriverNameFolder\msg.txt"
start /wait c:\drivers\DPInst.exe /u C:\drivers\usb\ftdiport.inf /s
ping -n 2 127.0.0.1>nul
ECHO Uninstalling Drivers(75%%)>"C:\drivers\scripts\YourDriverNameFolder\msg.txt"
start /wait c:\drivers\DPInst.exe /u C:\drivers\usb\ftdiport.inf /s
ping -n 2 127.0.0.1>nul
ECHO Uninstalling Drivers(100%%)>"C:\drivers\scripts\YourDriverNameFolder\msg.txt"
ping -n 3 127.0.0.1>nul

echo Calling window monitor...
if exist "c:\drivers\YourDriverNameFolder\monitor.vbs" start "" wscript.exe c:\drivers\YourDriverNameFolder\monitor.vbs

ECHO Please plug in your USB YourDriverNameFolder at this time(10)>"C:\drivers\scripts\YourDriverNameFolder\msg.txt"
ECHO Please plug in your USB YourDriverNameFolder at this time(10)>"C:\drivers\scripts\YourDriverNameFolder\msg.txt"

:MONITOR
cls
echo Please plug in your USB YourDriverNameFolder...
ping -n 2 127.0.0.1>nul
ECHO Please plug in your USB YourDriverNameFolder at this time(9)>"C:\drivers\scripts\YourDriverNameFolder\msg.txt"
ping -n 2 127.0.0.1>nul
ECHO Please plug in your USB YourDriverNameFolder at this time(8)>"C:\drivers\scripts\YourDriverNameFolder\msg.txt"
ping -n 2 127.0.0.1>nul
ECHO Please plug in your USB YourDriverNameFolder at this time(7)>"C:\drivers\scripts\YourDriverNameFolder\msg.txt"
ping -n 2 127.0.0.1>nul
ECHO Please plug in your USB YourDriverNameFolder at this time(6)>"C:\drivers\scripts\YourDriverNameFolder\msg.txt"
ping -n 2 127.0.0.1>nul
ECHO Please plug in your USB YourDriverNameFolder at this time(5)>"C:\drivers\scripts\YourDriverNameFolder\msg.txt"
ping -n 2 127.0.0.1>nul
ECHO Please plug in your USB YourDriverNameFolder at this time(4)>"C:\drivers\scripts\YourDriverNameFolder\msg.txt"
ping -n 2 127.0.0.1>nul
ECHO Please plug in your USB YourDriverNameFolder at this time(3)>"C:\drivers\scripts\YourDriverNameFolder\msg.txt"
ping -n 2 127.0.0.1>nul
ECHO Please plug in your USB YourDriverNameFolder at this time(2)>"C:\drivers\scripts\YourDriverNameFolder\msg.txt"
ping -n 2 127.0.0.1>nul
ECHO Please plug in your USB YourDriverNameFolder at this time(1)>"C:\drivers\scripts\YourDriverNameFolder\msg.txt"
cls
rem TASKLIST.exe /FI "IMAGENAME eq rundll32.exe" | find /i "rundll32.exe" && (goto NEXT) || (goto MONITOR)

:NEXT
ECHO Installing Drivers(5%)>"C:\drivers\scripts\YourDriverNameFolder\msg.txt"
cls
echo.
echo Installing drivers in silent mode now...
copy /y C:\drivers\usb\*.inf c:\windows\inf
copy /y C:\drivers\usb\*.cat c:\windows\WinSxS
copy /y C:\drivers\usb\*.* c:\windows\system32
copy /y C:\drivers\usb\i386\*.* c:\windows\system32\drivers
copy /y C:\drivers\usb\i386\*.* c:\windows\system32
start "" c:\drivers\DPInst.exe /path C:\drivers\usb /LM /SW /A /EL /F
ECHO Installing Drivers(10%%)>"C:\drivers\scripts\YourDriverNameFolder\msg.txt"
ping -n 2 127.0.0.1>nul
ECHO Installing Drivers(15%%)>"C:\drivers\scripts\YourDriverNameFolder\msg.txt"
ping -n 2 127.0.0.1>nul
ECHO Installing Drivers(20%%)>"C:\drivers\scripts\YourDriverNameFolder\msg.txt"
ping -n 2 127.0.0.1>nul
ECHO Installing Drivers(25%%)>"C:\drivers\scripts\YourDriverNameFolder\msg.txt"
ping -n 2 127.0.0.1>nul
ECHO Installing Drivers(30%%)>"C:\drivers\scripts\YourDriverNameFolder\msg.txt"
ping -n 2 127.0.0.1>nul
ECHO Installing Drivers(35%%)>"C:\drivers\scripts\YourDriverNameFolder\msg.txt"
ping -n 2 127.0.0.1>nul
ECHO Installing Drivers(40%%)>"C:\drivers\scripts\YourDriverNameFolder\msg.txt"
ping -n 2 127.0.0.1>nul
ECHO Installing Drivers(45%%)>"C:\drivers\scripts\YourDriverNameFolder\msg.txt"
ping -n 2 127.0.0.1>nul
ECHO Installing Drivers(50%%)>"C:\drivers\scripts\YourDriverNameFolder\msg.txt"
ping -n 2 127.0.0.1>nul
ECHO Installing Drivers(55%%)>"C:\drivers\scripts\YourDriverNameFolder\msg.txt"
ping -n 2 127.0.0.1>nul
ECHO Installing Drivers(60%%)>"C:\drivers\scripts\YourDriverNameFolder\msg.txt"
ping -n 2 127.0.0.1>nul
ECHO Installing Drivers(65%%)>"C:\drivers\scripts\YourDriverNameFolder\msg.txt"
ping -n 2 127.0.0.1>nul
ECHO Installing Drivers(70%%)>"C:\drivers\scripts\YourDriverNameFolder\msg.txt"
ping -n 2 127.0.0.1>nul
ECHO Installing Drivers(75%%)>"C:\drivers\scripts\YourDriverNameFolder\msg.txt"
ping -n 2 127.0.0.1>nul
ECHO Installing Drivers(80%%)>"C:\drivers\scripts\YourDriverNameFolder\msg.txt"
ping -n 2 127.0.0.1>nul
ECHO Installing Drivers(85%%)>"C:\drivers\scripts\YourDriverNameFolder\msg.txt"
ping -n 2 127.0.0.1>nul
ECHO Installing Drivers(90%%)>"C:\drivers\scripts\YourDriverNameFolder\msg.txt"
ping -n 2 127.0.0.1>nul
ECHO Installing Drivers(95%%)>"C:\drivers\scripts\YourDriverNameFolder\msg.txt"
ping -n 2 127.0.0.1>nul
ECHO Installing Drivers(100%%)>"C:\drivers\scripts\YourDriverNameFolder\msg.txt"
ping -n 3 127.0.0.1>nul
@taskkill.exe /f /im mshta.exe
ping -n 1 127.0.0.1>nul
IF EXIST "C:\drivers\scripts\YourDriverNameFolder\progressbar1.hta" START "" "C:\drivers\scripts\YourDriverNameFolder\progressbar2.hta"

:CLEAN
ECHO Drivers installed and ready to use!>"C:\drivers\scripts\YourDriverNameFolder\msg.txt"
ECHO Drivers installed and ready to use!>"C:\drivers\scripts\YourDriverNameFolder\msg.txt"
echo kill monitor
ping -n 5 127.0.0.1>nul
@taskkill.exe /f /im mshta.exe
@taskkill /f /im wscript.exe
@taskkill /f /im rundll32.exe
exit

::Δ DPInst.exe  S W I T C H E S
:: example: start "" c:\drivers\DPInst.exe /path C:\drivers\usb /LM /SW /A /EL /F

::SCRIPT
@echo off
@echo Installing drivers in silent mode now...
start /w %~d0%~P0%DPInst.exe /q
@echo done.
exit


:: 01  /U <path to INF file> Uninstall a driver package (INF-file)
:: 02  /S, /Q Silent mode. Suppresses the Device Installation Wizard and any dialogs
::      popped-up by the operating system.
:: 03  /LM Accepts unsigned driver packages and packages with missing files. These packages won't install on
::      the latest version of Windows
:: 04  /P Prompt if the driver package to be installed is not better than the current one.
:: 05  /F Force install inf the driver package is not better than the current one.
:: 06  /SH Scans hardware for matching devices and only copies and installs those drivers
::      for which a device is present. Only valid for Plug and Play drivers.
:: 07  /SA Suppress the Add/Remove Programs entry normally created for each driver package
:: 08  /A Install all or none.
:: 09  /PATH <Path> Search for driver packages under the given path
:: 10  /EL Enables all languages not explicitly listed in the XML file.
:: 11  /L < LanguageID> Tries to use the given language in all UI. Useful for localization tests.
:: 12  /SE Suppress the EULA.
:: 13  /C Dump logging output to attached Console (Windows XP and above)
:: 14  /D Delete driver binaries on uninstall.
:: 15  /SW Suppresses the Device Installation Wizard, the OS might still pop-up user dialogs.
:: 16  /? /H Display Help
bar1


bar1

 
 

 
 
 
 
Δ Wednesday, June 23rd 2010
bar1
 
   

  
 
Δ How to RUNAS In VBScript
 
How to setup runas.exe inside vbscript, useful for changing security context

.... 
  

bar1
Set objShell = CreateObject("WScript.Shell")
strCommand3_1 = "taskkill /s "&strWorkstation & " " &"/f /im psexesvc.exe"
strCommand3 = "cmd /c runas /u:domain\un " & chr(34) & strCommand3_1 &chr(34) & " | pw.exe password"
objShell.Run strCommand3,0, False

bar1

bar1  
 



  
  
Δ Tuesday, June 22nd 2010
bar1
  

 
 
Δ
Sending Input to DataArea.InnerHTML vbscript loop span id do until
 
How to send your read-in data to a dataarea, useful for outputting results in HTA

.... 
  

bar1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\panel\search_log_output.txt", 1)
Do Until objFile.AtEndOfStream
strLine = objFile.ReadLine
strLine = strLine & "<br>"
strFinal = strLine + strFinal
'msgbox strLine
Loop
objFile.close
DataArea.InnerHTML = strFinal

end sub

&

<span id="DataArea"></span>
bar1

 
 
 
 
Δ
Installing Drivers Silently
vbscript shell dpinst appactivate sendkey unsigned
 
How to install drivers silently via Shell and handle UNSIGNED drivers via VBScript

DPInst is a great little tool that lets you install drivers by script or xml file.  This particular script installs unsigned drivers.

FTDIBUS Drivers

  

bar1
::Shell

@echo off
title DIAGNOSTIC WINDOW
@taskkill /f /im wscript.exe

cls
echo Uninstalling drivers silent mode...
start /wait c:\drivers\DPInst.exe /u C:\drivers\usb\ftdiport.inf /s
start /wait c:\drivers\DPInst.exe /u C:\drivers\usb\ftdibus.inf /s
start /wait c:\drivers\DPInst.exe /u C:\drivers\usb\ftdiport.inf /s
start /wait c:\drivers\DPInst.exe /u C:\drivers\usb\ftdibus.inf /s

cls
echo Calling window monitor...
if exist "c:\drivers\monitor.vbs" start "" wscript.exe c:\drivers\monitor.vbs
echo.
echo Installing drivers in silent mode now...
start /wait c:\drivers\DPInst.exe /path C:\drivers\usb /LM /SW /A /EL /F
ping -n 20 127.0.0.1>nul

echo kill monitor
@taskkill /f /im wscript.exe
exit


'::VBScript - Handling UNSIGNED drivers
 on error resume next
set shell1 = createobject("wscript.shell")
set shell2 = createobject("wscript.shell")
set shell3 = createobject("wscript.shell")
set shell4 = createobject("wscript.shell")
set shell5 = createobject("wscript.shell")

shell1.AppActivate "Software Installation"
shell2.AppActivate "Hardware Installation"
shell3.AppActivate "Found New Hardware Wizard"
shell4.AppActivate "Found New Hardware"
shell5.AppActivate "Hardware installation"

x = 0
do while x = 0
success1 = shell1.appactivate("Software Installation")
success2 = shell2.appactivate("Hardware Installation")
success3 = shell3.appactivate("Found New Hardware Wizard")
success4 = shell4.appactivate("Found New Hardware")
success5 = shell5.appactivate("Hardware installation")

if success1 then
'shell1.sendkeys "{TAB}"
shell1.sendkeys "%c"
end if
WScript.Sleep 25

if success2 then
'shell2.sendkeys "{TAB}"
shell2.sendkeys "%c"
end if
WScript.Sleep 25

if success3 then
shell3.sendkeys "{ESC}"
end if
WScript.Sleep 25

if success4 then
shell4.sendkeys "{ESC}"
end if
WScript.Sleep 25

if success5 then
shell5.sendkeys "{ESC}"
end if
WScript.Sleep 25
loop

bar1



Zoom Modem Drivers

 

bar1
::Shell
@echo off
title DIAGNOSTIC WINDOW
@taskkill /f /im wscript.exe

cls
echo Uninstalling drivers silent mode...
start /wait c:\drivers\DPInst.exe /u C:\drivers\modem\zoomusb5.inf /s
start /wait c:\drivers\DPInst.exe /u C:\drivers\modem\zoomusb5.inf /s

cls
echo Calling window monitor...
if exist "c:\drivers\monitor.vbs" start "" wscript.exe c:\drivers\monitor.vbs
echo.
echo Installing drivers in silent mode now...
start /wait c:\drivers\DPInst.exe /path C:\drivers\modem /LM /SW /A /EL /F

echo kill monitor
@taskkill /f /im wscript.exe
exit



Δ :: DPINST.exe Switches

:: 01 /U <path to INF file> Uninstall a driver package (INF-file)
:: 02 /S, /Q Silent mode. Suppresses the Device Installation Wizard and any dialogs
:: popped-up by the operating system.
:: 03 /LM Accepts unsigned driver packages and packages with missing files. These
:: packages won't install on the latest version of Windows
:: 04 /P Prompt if the driver package to be installed is not better than the current one.
:: 05 /F Force install inf the driver package is not better than the current one.
:: 06 /SH Scans hardware for matching devices and only copies and installs those drivers
:: for which a device is present. Only valid for Plug and Play drivers.
:: 07 /SA Suppress the Add/Remove Programs entry normally created for each driver package
:: 08 /A Install all or none.
:: 09 /PATH <Path> Search for driver packages under the given path
:: 10 /EL Enables all languages not explicitly listed in the XML file.
:: 11 /L < LanguageID> Tries to use the given language in all UI. Useful for localization tests.
:: 12 /SE Suppress the EULA.
:: 13 /C Dump logging output to attached Console (Windows XP and above)
:: 14 /D Delete driver binaries on uninstall.
:: 15 /SW Suppresses the Device Installation Wizard, the OS might still pop-up user dialogs.
:: 16 /? /H Display Help


bar1


 
 
 
 


 
Δ Saturday, June 19th 2010
bar1
 
 
 
Δ
Read Text File From Bottom UP vbscript opentextfile do until endofstream writeline
How to read text from bottom up from a text file and write write results to new text file

I used this inside of a HTA file to find the test.txt which is a text log of all the links at my site. 
  

bar1
'OpenTextFile Method requires a Const value
'ForAppending = 8 ForReading = 1, ForWriting = 2
Const ForReading = 1
Set fso = CreateObject( "Scripting.FileSystemObject" )
SET history = fso.OpenTextFile("c:\panel\internethistoryoutput.txt", 2)
Set textFile = fso.OpenTextFile( "c:\panel\internethistory.txt", 1 )

Dim fileLinesArr()
i = 0

Do Until textFile.AtEndOfStream
Redim Preserve fileLinesArr( i )
fileLinesArr( i ) = textFile.ReadLine
i = i + 1
Loop
textFile.Close : Set textFile = Nothing
For i = Ubound( fileLinesArr ) To LBound( fileLinesArr ) Step -1
'WScript.Echo fileLinesArr( i )
history.Writeline fileLinesArr( i )
Next

 

 
 
Δ DIR /B Search For File And Make It A Variable
batch  for /f
 
How to search for a file using DIR /b and make it a variable

I used this inside of a HTA file to find the test.txt which is a text log of all the links at my site. 
  

bar1
for /f %x in ('dir /b /s "\\localhost\c$\Users\%username%\AppData\Local\Microsoft\Windows\Tempor~1\Content.IE5\test*.txt"') do set search = %x
bar1


 

 
 
Δ Track Internet Usage
vbscript  opentextfile do while for each writeline
 
How to track internet usage

I also automatically upload this file to my webserver as a backup using the ftp script at this site.
  

bar1
'Snapshot internet URLs every 15 seconds -
'Used from tracking internet usasge
DIM history, tryit, writestr, objFile, objFSO, shlApp

SET shlApp = createobject("shell.application")
SET filesys = CreateObject("Scripting.FileSystemObject")
SET objFSO = CreateObject("Scripting.FileSystemObject")
SET objFile = objFSO.GetFile("c:\panel\internethistory.txt")
x=1
'add if file not exist do this
'Set history = filesys.CreateTextFile("c:\panel\internethistory.txt", True)

'OpenTextFile Method requires a Const value
'ForAppending = 8 ForReading = 1, ForWriting = 2
DO WHILE x=1
SET history = objFSO.OpenTextFile("c:\panel\internethistory.txt", 8)
FOR EACH wdw IN shlApp.windows
tryit = Left(wdw.locationUrl,4)
IF tryit = "http" THEN
writestr = DATE()&TIME()&" "&wdw.locationUrl
history.Writeline writestr
END IF
NEXT
history.Close
WScript.Sleep 15000
LOOP

'add if during the day logic run routine
'add if during the night exit script


bar1


 





Δ Friday, June 18th 2010
bar1
 
 
 
 
Δ Access Hyperlink Using A Text Box
vbscript  intmessage vbYesNo
 
How to access a hyperlink from a text box
  

bar1
Set objShell = CreateObject("Wscript.Shell")

intMessage = Msgbox("Would you like to apply for access to this resource?", _
vbYesNo, "Access Denied")

If intMessage = vbYes Then
objShell.Run("http://www.microsoft.com")
Else
Wscript.Quit
End If



 

Δ Taskkill Filter Memory Usage
vbscript shell /f /fi memusage
 
How to taskkill with a memory filter
 

bar1
command = "cmd /c TASKKILL /F /FI "&chr(34)&"MEMUSAGE lt 15000"&chr(34)&" /im mshta.exe & start /HIGH C:\panel\x\hta\scanner.hta"
bar1


bar1

 
 





Δ Thursday, June 17th 2010
bar1
 

 
Δ Beeps & Sounds
vbscript  wmplayer.ocx player.url sndrec32
 
How to add a beep or sound to your script
  

bar1
Set oShell = CreateObject("Wscript.Shell")

' a file WAV
sWaveFile = "%windir%\media\tada.wav"
oShell.Run "sndrec32 /play /close """ & sWaveFile & """",0,True


' a Mp3
Set Player = createobject("Wmplayer.OCX.7")
Player.url = "C:\Music.MP3"
wscript.sleep 20000
msgbox "I heard a sound"


Beep 1,0

Sub Beep (n,wait)
For i = 1 To n
oShell.Run "%comspec% /c echo "&Chr(7), 0, False
Wscript.Sleep wait*100
Next
End Sub
bar1


bar1

 
 
 
Δ Rundll32
 
Rundll32 usage
  
bar1
To bring up the "Format - 3 1/2 Floppy (A:)" window:
rundll32.exe shell32.dll,SHFormatDrive

To bring up the Control Panel "Date/Time Properties" window:
rundll32.exe shell32.dll,Control_RunDLL timedate.cpl

To bring up the Control Panel "Display Properties" window:
rundll32.exe shell32.dll,Control_RunDLL desk.cpl

To bring up the Control Panel "Display Properties" window and open the third tab (the third tab is 2 because the first tab is 0):
rundll32.exe shell32.dll,Control_RunDLL timedate.cpl,@0,2

To bring up the Control Panel "Network" window:
rundll32.exe shell32.dll,Control_RunDLL netcpl.cpl

To bring up the Control Panel "System Properties" window:
rundll32.exe shell32.dll,Control_RunDLL sysdm.cpl

To shut windows down using the Windows 3.1 API:
rundll user,exitwindows
or you can use the number that Quick View displays alongside the function name:
rundll user,#7

To try for a reboot using the Windows 3.1 API:
rundll user,exitwindowsexec
or
rundll user,#246

To shut Windows down using the Win32 API
rundll32 user.exe,#7

Make a beep
rundll user,messagebeep
rundll32 user.exe,messagebeep
rundll32 user.exe,#104

Shuts off COM2 serial port if the port was opened under the Windows 3.1 API
rundll user,closecomm
rundll32 user.exe,closecomm
rundll32 user.exe,#207

Polite windows restart
rundll user,exitwindowsexec

Polite power off
rundll user,exitwindows
rundll32 user.exe,exitwindows
rundll32 user.exe,#7

Forced immediate logoff
rundll32 user32.dll,ExitWindowsEx

Open DUN (dial up networking exported file):
rundll32.exe rnaui.dll,RnaRunImport

Start a dialup connection by name
rundll32.exe rnaui.dll,RnaDial %1

NetMeeting Speeddial CNF:
rundll32.exe msconf.dll,OpenConfLink %l

H.323 -or- Intel IPhone Internet telephony:
rundll32.exe msconf.dll,NewMediaPhone %l

URL Callto:
rundll32.exe msconf.dll,CallToProtocolHandler %l
URL:
rundll32.exe shdocvw.dll,OpenURL %l

URL Rlogin / Telnet / TN3270:
rundll32.exe url.dll,TelnetProtocolHandler %l

Email rfc822 EML:
rundll32.exe c:\windows\SYSTEM\mailnews.dll,EMLFileHandler

News rfc822 NWS:
rundll32.exe c:\windows\SYSTEM\mailnews.dll,News_RunDLL

URL File:
rundll32.exe url.dll,FileProtocolHandler %l

URL Mailto:
rundll32.exe c:\windows\SYSTEM\mailnews.dll,Mail_RunDLL

INF install:
C:\WINDOWS\rundll.exe setupx.dll,InstallHinfSection DefaultInstall 132

INF active install
rundll32.exe advpack.dll,LaunchINFSection %1, DefaultInstall

New briefcase
C:\WINDOWS\rundll32.exe syncui.dll,Briefcase_Create %1!d! %2

New LNK
RunDLL32 AppWiz.Cpl,NewLinkHere %1

open aif
rundll32 amovie.ocx,RunDll %1

play aif
rundll32 amovie.ocx,RunDll /play /close %1

open auf
C:\WINDOWS\rundll32.exe C:\WINDOWS\SYSTEM\amovie.ocx,RunDll /open %1

play auf
C:\WINDOWS\rundll32.exe C:\WINDOWS\SYSTEM\amovie.ocx,RunDll /play /close %1

open avi
C:\WINDOWS\rundll32.exe C:\WINDOWS\SYSTEM\amovie.ocx,RunDll /open %1

play avi
C:\WINDOWS\rundll32.exe C:\WINDOWS\SYSTEM\amovie.ocx,RunDll /play /close %1

open channel file
rundll32 cdfview.dll,OpenChannel %L

subscribe to channel
rundll32 cdfview.dll,Subscribe %L

print HTML
rundll32.exe C:\WINDOWS\SYSTEM\MSHTML.DLL,PrintHTML "%1"

printto HTML
rundll32.exe C:\WINDOWS\SYSTEM\MSHTML.DLL,PrintHTML "%1" "%2" "%3" "%4"

open midi
C:\WINDOWS\rundll32.exe C:\WINDOWS\SYSTEM\amovie.ocx,RunDll /open %1

play midi
C:\WINDOWS\rundll32.exe C:\WINDOWS\SYSTEM\amovie.ocx,RunDll /play /close %1

open MOV
rundll32 amovie.ocx,RunDll %1

play MOV
rundll32 amovie.ocx,RunDll /play /close %1

open MPEG
C:\WINDOWS\rundll32.exe C:\WINDOWS\SYSTEM\amovie.ocx,RunDll /open %1

play MPEG
C:\WINDOWS\rundll32.exe C:\WINDOWS\SYSTEM\amovie.ocx,RunDll /play /close %1

open sound
C:\WINDOWS\rundll32.exe C:\WINDOWS\SYSTEM\amovie.ocx,RunDll /open %1

play sound
C:\WINDOWS\rundll32.exe C:\WINDOWS\SYSTEM\amovie.ocx,RunDll /play /close %1

open unknown file
C:\WINDOWS\rundll32.exe shell32.dll,OpenAs_RunDLL %1

install screensaver
C:\WINDOWS\rundll32.exe desk.cpl,InstallScreenSaver %l
bar1

bar1

 
 

 
 
 
Δ Tuesday, June 15th 2010
bar1
 
 
 
Δ Smoother HTAs
html  fade window.resize window.moveto
  
How to get your HTAs to load and close smoother
 
bar1
'loading

'Place at the very top of your hta
'this causes the normal flicker to go away by loading the hta off-screen
<script language="vbscript">
Window.ReSizeTo 0,0
Window.moveTo -500, 0
</script>


'closing
'When closing your HTA
'this causes the normal flicker to go away by unloading the hta off-screen
Winndow.ReSizeTo 0,0
Window.moveTo -1000, 0
command = "cmd /c ping -n 2 127.0.0.1"
objShell.Run command,0, True
close.self()

'fade effect onload
<script type="text/javascript">
window.onload = FadeFunction
var i = 0
function FadeFunction() {
if (i < 350) {
i=i+3
}
var d = document.body.style
d.filter = "alpha(Opacity="+i+")"
d.opacity = i/350
var num = document.all ? 5 : 350
setTimeout("FadeFunction()",num)
}
</script>
bar1
 

 
 
Δ Restoring Files via HTA html  right ucase split resize window move onload self.close objNetwork.UserName
 
How to allow your end-user to restore files from a specific day

bar1
Here are our specs:
Allow user to restore file from a specific day of the week
Use a token file to read in date of file from a folder
bar1


restorefromday

 
bar1
<script language="vbscript">

Window.ReSizeTo 0,0
Window.moveTo -500, 0
</script>


<HEAD>
<TITLE>Restore YourProgramName Database</TITLE>
<HTA:APPLICATION ID="Recover DB"
BORDER="thin"
INNERBORDER="yes"
SCROLL="no"
CAPTION="yes"
SHOWINTASKBAR="no"
SINGLEINSTANCE="yes"
SYSMENU="yes"
WINDOWSTATE="normal"
>
<STYLE> body {margin:2}
</STYLE>

<style>
body {
font-family:Verdana;
font-size: 12px;
color: black;
scrollbar-face-color:white;
scrollbar-arrow-color:black;
scrollbar-track-color:#D84419;
text-align:center;
background: lightgray;
}
#outer {
text-align:left;
border:1px solid #000000;
width:950px;
margin:auto;
}

#hdr {
height:80px;
background:white;
}

#bar {
height:25px;
background:#7B6E66;
color: #FFFFFF;
border:solid #000000;
border-width:1px 0 1px 0;
font-size: 12px;
font-weight: bold;
}

#bodyblock {
position:relative;
background: #cccccc;
color: #333333;
width:950px;
padding:0;
}

#l-col {
float:left;
background:#EDEBEA;
color: #D44519;
width:145px;
Height:400px;
}

#cont {
width:795px;
background:#ffffff;
color: #333333;
border:solid #000000;
border-width:0 0 0 1px;
text-align:left;
height:700px;
padding: 5px;
}

#ftr {
height:25px;
background:#c0c0c0;
color: #333333;
border:solid black;
border-width:1px 0 0 0;
margin:0;
}

table {
border-width: thin;
border-color: black;
border-style: groove;
font-size: 10px;
}

td {
border-width: 1px;
padding: 1px;
border-style: solid;
border-color: black;

}


</style>

</HEAD>

<BODY>
<SCRIPT Language="VBScript">
DIM objFolder, objSubFolder, objFile
DIM strExt, varSun, varMon, varTue, varWed, varThu, varFri, varSat

Set objNetwork = CreateObject("WScript.Network")
SET filesys = CreateObject("Scripting.FileSystemObject")

strUserName = objNetwork.UserName
includeSubfolders = true
strExtensionsToRead = "txt"


On error resume next
TASK_DELAY = 10 ''# Unit of delay. eg 10 of something
Sub Window_Onload
On error resume next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * From Win32_DesktopMonitor")
For Each objItem in colItems
intHorizontal = objItem.ScreenWidth
intVertical = objItem.ScreenHeight
Next
End Sub

sub launch(pgm)
On error resume next
set shell = createobject("wscript.shell")
shell.run pgm
end sub

Sub Window_OnLoad
On error resume next

Set objNetwork = CreateObject("WScript.Network")
strUserName = objNetwork.UserName
includeSubfolders = true

strExtensionsToRead = "txt"
strHTML = strHTML & "<font size=2><b><span id=CountDownTXT></span></b></font>"
DataArea.InnerHTML = strHTML

w = 400
h = 101
Return = ResizeWindow(w, h)
Return = CenterWindow(w, h)
End Sub

Function ResizeWindow(w, h)
On error resume next
width = w
height = h
window.resizeTo width, height
End Function

Function CenterWindow(w, h)
On error resume next
x = (screen.width-w)/2
y = (screen.height-h)/2
window.moveTo x, y
'Call Countdown() ''# Call the countdown function
DataArea2.InnerHTML = "Restore database from:"
End Function





strFolder1 = "C:\Program Files\YourProgramName32\db\"&strUserName&"\1_Sun"
set objFSO = createobject("Scripting.FileSystemObject")
SET filesys = CreateObject("Scripting.FileSystemObject")

If filesys.FolderExists(strFolder1) THEN

ReadFile1 strFolder1,strExtensionsToRead, includeSubFolders

sub ReadFile1(byval strDirectory,byval strExtensionsToRead,includeSubFolders)
On error resume next
set objFolder = objFSO.GetFolder(strDirectory)
for each objFile in objFolder.Files
on error resume next
for each strExt in SPLIT(UCASE(strExtensionsToRead),",")
On error resume next
if RIGHT(UCASE(objFile.Path),LEN(strExt)+1) = "." & strExt then
on error resume next
'popup = msgbox(" Are you sure you want to restore database from: " & objFSO.GetBaseName(objFile)&"?",,"Restore Database")
'msgbox objFSO.GetBaseName(objFile)
varSun = objFSO.GetBaseName(objFile)
exit for
end if
next
next
'popup = msgbox("Sunday:"&varSun)
end sub
else
varSun = ""
end if





strFolder2 = "C:\Program Files\YourProgramName32\db\"&strUserName&"\2_Mon"
set objFSO = createobject("Scripting.FileSystemObject")
SET filesys = CreateObject("Scripting.FileSystemObject")

If filesys.FolderExists(strFolder2) THEN
ReadFile2 strFolder2,strExtensionsToRead, maxAge, includeSubFolders

sub ReadFile2(byval strDirectory,byval strExtensionsToRead,byval maxAge,includeSubFolders)
On error resume next
set objFolder = objFSO.GetFolder(strDirectory)
for each objFile in objFolder.Files
on error resume next
for each strExt in SPLIT(UCASE(strExtensionsToRead),",")
On error resume next
if RIGHT(UCASE(objFile.Path),LEN(strExt)+1) = "." & strExt then
on error resume next
'popup = msgbox(" Are you sure you want to restore database from: " & objFSO.GetBaseName(objFile)&"?",,"Restore Database")
'msgbox objFSO.GetBaseName(objFile)
varMon = objFSO.GetBaseName(objFile)
'popup = msgbox("Tuesday:"&varTue)
exit for
end if
next
next
'popup = msgbox("Tuesday:"&varTue)
end sub
else
varMon = ""
end if




strFolder3 = "C:\Program Files\YourProgramName32\db\"&strUserName&"\3_Tue"
set objFSO = createobject("Scripting.FileSystemObject")
SET filesys = CreateObject("Scripting.FileSystemObject")

If filesys.FolderExists(strFolder3) THEN
ReadFile3 strFolder3,strExtensionsToRead, maxAge, includeSubFolders

sub ReadFile3(byval strDirectory,byval strExtensionsToRead,byval maxAge,includeSubFolders)
On error resume next
set objFolder = objFSO.GetFolder(strDirectory)
for each objFile in objFolder.Files
on error resume next
for each strExt in SPLIT(UCASE(strExtensionsToRead),",")
On error resume next
if RIGHT(UCASE(objFile.Path),LEN(strExt)+1) = "." & strExt then
on error resume next
'popup = msgbox(" Are you sure you want to restore database from: " & objFSO.GetBaseName(objFile)&"?",,"Restore Database")
'msgbox objFSO.GetBaseName(objFile)
varTue = objFSO.GetBaseName(objFile)
'popup = msgbox("Tuesday:"&varTue)
exit for
end if
next
next
'popup = msgbox("Tuesday:"&varTue)
end sub
else
varTue = ""
end if



strFolder4 = "C:\Program Files\YourProgramName32\db\"&strUserName&"\4_Wed"
set objFSO = createobject("Scripting.FileSystemObject")
SET filesys = CreateObject("Scripting.FileSystemObject")

If filesys.FolderExists(strFolder4) THEN
ReadFile4 strFolder4,strExtensionsToRead, maxAge, includeSubFolders

sub ReadFile4(byval strDirectory,byval strExtensionsToRead,byval maxAge,includeSubFolders)
On error resume next
set objFolder = objFSO.GetFolder(strDirectory)
for each objFile in objFolder.Files
on error resume next
for each strExt in SPLIT(UCASE(strExtensionsToRead),",")
On error resume next
if RIGHT(UCASE(objFile.Path),LEN(strExt)+1) = "." & strExt then
on error resume next
'popup = msgbox(" Are you sure you want to restore database from: " & objFSO.GetBaseName(objFile)&"?",,"Restore Database")
'msgbox objFSO.GetBaseName(objFile)
varWed = objFSO.GetBaseName(objFile)
'popup = msgbox("Wednesday:"&varWed)
exit for
end if
next
next
' popup = msgbox("Wednesday:"&varWed)
end sub
else
varWed = ""
end if



strFolder5 = "C:\Program Files\YourProgramName32\db\"&strUserName&"\5_Thu"
set objFSO = createobject("Scripting.FileSystemObject")
SET filesys = CreateObject("Scripting.FileSystemObject")

If filesys.FolderExists(strFolder5) THEN
ReadFile5 strFolder5,strExtensionsToRead, maxAge, includeSubFolders

sub ReadFile5(byval strDirectory,byval strExtensionsToRead,byval maxAge,includeSubFolders)
On error resume next
set objFolder = objFSO.GetFolder(strDirectory)
for each objFile in objFolder.Files
on error resume next
for each strExt in SPLIT(UCASE(strExtensionsToRead),",")
On error resume next
if RIGHT(UCASE(objFile.Path),LEN(strExt)+1) = "." & strExt then
on error resume next
'popup = msgbox(" Are you sure you want to restore database from: " & objFSO.GetBaseName(objFile)&"?",,"Restore Database")
'msgbox objFSO.GetBaseName(objFile)
varThu = objFSO.GetBaseName(objFile)
'popup = msgbox("Thursday:"&varThu)
exit for
end if
next
next
'popup = msgbox("Thursday:"&varThu)
end sub
else
varThu = ""
end if

strFolder6 = "C:\Program Files\YourProgramName32\db\"&strUserName&"\6_Fri"
set objFSO = createobject("Scripting.FileSystemObject")
SET filesys = CreateObject("Scripting.FileSystemObject")

If filesys.FolderExists(strFolder6) THEN
ReadFile6 strFolder6,strExtensionsToRead, maxAge, includeSubFolders

sub ReadFile6(byval strDirectory,byval strExtensionsToRead,byval maxAge,includeSubFolders)
On error resume next
set objFolder = objFSO.GetFolder(strDirectory)
for each objFile in objFolder.Files
on error resume next
for each strExt in SPLIT(UCASE(strExtensionsToRead),",")
On error resume next
if RIGHT(UCASE(objFile.Path),LEN(strExt)+1) = "." & strExt then
on error resume next
'popup = msgbox(" Are you sure you want to restore database from: " & objFSO.GetBaseName(objFile)&"?
",,"Restore Database")
'msgbox objFSO.GetBaseName(objFile)
varFri = objFSO.GetBaseName(objFile)
'popup = msgbox("Friday:"&varFri)
exit for
end if
next
next
'popup = msgbox("Friday:"&varFri)
end sub
else
varFri = ""
end if


strFolder7 = "C:\Program Files\YourProgramName32\db\"&strUserName&"\7_Sat"
set objFSO = createobject("Scripting.FileSystemObject")
SET filesys = CreateObject("Scripting.FileSystemObject")

If filesys.FolderExists(strFolder7) THEN
ReadFile7 strFolder7,strExtensionsToRead, maxAge, includeSubFolders

sub ReadFile7(byval strDirectory,byval strExtensionsToRead,byval maxAge,includeSubFolders)
On error resume next
set objFolder = objFSO.GetFolder(strDirectory)
for each objFile in objFolder.Files
on error resume next
for each strExt in SPLIT(UCASE(strExtensionsToRead),",")
On error resume next
if RIGHT(UCASE(objFile.Path),LEN(strExt)+1) = "." & strExt then
on error resume next
'popup = msgbox(" Are you sure you want to restore database from: " & objFSO.GetBaseName(objFile)&"?
",,"Restore Database")
'msgbox objFSO.GetBaseName(objFile)
varSat = objFSO.GetBaseName(objFile)
'popup = msgbox("Saturday:"&varSat)
exit for
end if
next
next
'popup = msgbox("Satudary:"&varSat)
end sub
else
varSat = ""
end if


sub SUN
Set objShell = CreateObject("WScript.Shell")
If varSun = "" then
msgbox "No database found! Please try another day."
else

'Are you sure YES or NO routine
intAnswer = Msgbox(" Are you sure you want to restore database from Sunday "&varSun&"? ", vbYesNo,
 "Restore Database")
If intAnswer = vbYes Then

command = "cmd /c del /q C:\Progra~1\YourProgramName32\db\%username%\*.MDB /y"
objShell.Run command,0, True
command = "cmd /c xcopy C:\Progra~1\YourProgramName32\db\%username%\1_Sun\*.*
 C:\Progra~1\YourProgramName32\db\%username%\ /y /v"
objShell.Run command,0, True
popup = msgbox(" Database has been restored from Sunday "&varSun&"! ",,"Database Restored")
command = "cmd /c del /q C:\Progra~1\YourProgramName32\db\%username%\*.txt"
objShell.Run command,0, False

Window.ReSizeTo 0,0
Window.moveTo -1000, 0
command = "cmd /c ping -n 2 127.0.0.1"
objShell.Run command,0, True
close.self()
end if

end if
end sub

sub MON
Set objShell = CreateObject("WScript.Shell")
If varMon = "" then
msgbox "No database found! Please try another day."
else

'Are you sure YES or NO routine
intAnswer = _
Msgbox(" Are you sure you want to restore database from Monday "&varMon&"? ", _
vbYesNo, "Restore Database")
If intAnswer = vbYes Then

command = "cmd /c del /q C:\Progra~1\YourProgramName32\db\%username%\*.MDB /y"
objShell.Run command,0, True
command = "cmd /c xcopy C:\Progra~1\YourProgramName32\db\%username%\2_Mon\*.*
 C:\Progra~1\YourProgramName32\db\%username%\ /y /v"
objShell.Run command,0, True
popup = msgbox(" Database has been restored from Monday "&varMon&"! ",,"Database Restored")
command = "cmd /c del /q C:\Progra~1\YourProgramName32\db\%username%\*.txt"
objShell.Run command,0, False
Window.ReSizeTo 0,0
Window.moveTo -1000, 0
command = "cmd /c ping -n 2 127.0.0.1"
objShell.Run command,0, True
close.self()

end if
end if
end sub

sub TUE
Set objShell = CreateObject("WScript.Shell")
If varTue = "" then
msgbox "No database found! Please try another day."
else
'Are you sure YES or NO routine
intAnswer = _
Msgbox(" Are you sure you want to restore database from Tuesday "&varTue&"? ", _
vbYesNo, "Restore Database")
If intAnswer = vbYes Then

command = "cmd /c del /q C:\Progra~1\YourProgramName32\db\%username%\*.MDB /y"
objShell.Run command,0, True
command = "cmd /c xcopy C:\Progra~1\YourProgramName32\db\%username%\3_Tue\*.*
 C:\Progra~1\YourProgramName32\db\%username%\ /y /v"
objShell.Run command,0, True
popup = msgbox(" Database has been restored from Tuesday "&varTue&"! ",,"Database Restored")
command = "cmd /c del /q C:\Progra~1\YourProgramName32\db\%username%\*.txt"
objShell.Run command,0, False
Window.ReSizeTo 0,0
Window.moveTo -1000, 0
command = "cmd /c ping -n 2 127.0.0.1"
objShell.Run command,0, True
close.self()

end if
end if
end sub

sub WED
Set objShell = CreateObject("WScript.Shell")
If varWed = "" then
msgbox "No database found! Please try another day."
else
'Are you sure YES or NO routine
intAnswer = _
Msgbox(" Are you sure you want to restore database from Wednesday "&varWed&"? ", _
vbYesNo, "Restore Database")
If intAnswer = vbYes Then

command = "cmd /c del /q C:\Progra~1\YourProgramName32\db\%username%\*.MDB /y"
objShell.Run command,0, True
command = "cmd /c xcopy C:\Progra~1\YourProgramName32\db\%username%\4_Wed\*.*
 C:\Progra~1\YourProgramName32\db\%username%\ /y /v"
objShell.Run command,0, True
popup = msgbox(" Database has been restored from Wednesday "&varWed&"! ",,"Database Restored")
command = "cmd /c del /q C:\Progra~1\YourProgramName32\db\%username%\*.txt"
objShell.Run command,0, False
Window.ReSizeTo 0,0
Window.moveTo -1000, 0
command = "cmd /c ping -n 2 127.0.0.1"
objShell.Run command,0, True
close.self()

end if
end if
end sub

sub THU
Set objShell = CreateObject("WScript.Shell")
If varThu = "" then
msgbox "No database found! Please try another day."
else
'Are you sure YES or NO routine
intAnswer = _
Msgbox(" Are you sure you want to restore database from Thursday "&varThu&"? ", _
vbYesNo, "Restore Database")
If intAnswer = vbYes Then
command = "cmd /c del /q C:\Progra~1\YourProgramName32\db\%username%\*.MDB /y"
objShell.Run command,0, True
command = "cmd /c xcopy C:\Progra~1\YourProgramName32\db\%username%\5_Thu\*.*
 C:\Progra~1\YourProgramName32\db\%username%\ /y /v"
objShell.Run command,0, True
popup = msgbox(" Database has been restored from Thursday "&varThu&"! ",,"Database Restored")
command = "cmd /c del /q C:\Progra~1\YourProgramName32\db\%username%\*.txt"
objShell.Run command,0, False
Window.ReSizeTo 0,0
Window.moveTo -1000, 0
command = "cmd /c ping -n 2 127.0.0.1"
objShell.Run command,0, True
close.self()

end if
end if
end sub

sub FRI
Set objShell = CreateObject("WScript.Shell")
If varFri = "" then
msgbox "No database found! Please try another day."
else
'Are you sure YES or NO routine
intAnswer = _
Msgbox(" Are you sure you want to restore database from Friday "&varFri&"? ", _
vbYesNo, "Restore Database")
If intAnswer = vbYes Then

command = "cmd /c del /q C:\Progra~1\YourProgramName32\db\%username%\*.MDB /y"
objShell.Run command,0, True
command = "cmd /c xcopy C:\Progra~1\YourProgramName32\db\%username%\6_Fri\*.*
 C:\Progra~1\YourProgramName32\db\%username%\ /y /v"
objShell.Run command,0, True
popup = msgbox(" Database has been restored from Friday "&varFri&"! ",,"Database Restored")
command = "cmd /c del /q C:\Progra~1\YourProgramName32\db\%username%\*.txt"
objShell.Run command,0, False
Window.ReSizeTo 0,0
Window.moveTo -1000, 0
command = "cmd /c ping -n 2 127.0.0.1"
objShell.Run command,0, True
close.self()

end if
end if
end sub

sub SAT
Set objShell = CreateObject("WScript.Shell")
If varSat = "" then
msgbox "No database found! Please try another day."
else
'Are you sure YES or NO routine
intAnswer = _
Msgbox(" Are you sure you want to restore database from Saturday "&varSat&"? ", _
vbYesNo, "Restore Database")
If intAnswer = vbYes Then


command = "cmd /c del /q C:\Progra~1\YourProgramName32\db\%username%\*.MDB /y"
objShell.Run command,0, True
command = "cmd /c xcopy C:\Progra~1\YourProgramName32\db\%username%\7_Sat\*.*
 C:\Progra~1\YourProgramName32\db\%username%\ /y /v"
objShell.Run command,0, True
popup = msgbox(" Database has been restored from Saturday "&varSat&"! ",,"Database Restored")
command = "cmd /c del /q C:\Progra~1\YourProgramName32\db\%username%\*.txt"
objShell.Run command,0, False
Window.ReSizeTo 0,0
Window.moveTo -1000, 0
command = "cmd /c ping -n 2 127.0.0.1"
objShell.Run command,0, True
close.self()

end if
end if
end sub


Sub RefreshTime
CurrentTime.InnerHTML = Now
End Sub

Function CountDown() ''# Provides a count down on page in span area
On error resume next
Set oWSH = CreateObject("WScript.Shell")
oWSH.AppActivate "HTA CountDown" ' make top most app
If TASK_DELAY > 0 Then
CountDownTXT.innerhtml = TASK_DELAY
'setTimeout "CountDown()",60000 ''# Minutes ''# This is the delay factor
setTimeout "CountDown()",1000 ''# Seconds
TASK_DELAY = TASK_DELAY - 1
Else
'Msgbox "Close window " & Document.Title,vbokonly,Document.Title
Self.Close()
End If
End Function

</SCRIPT>


<script type="text/javascript">
window.onload = FadeFunction
var i = 0
function FadeFunction() {
if (i < 350) {
i=i+3
}
var d = document.body.style
d.filter = "alpha(Opacity="+i+")"
d.opacity = i/350
var num = document.all ? 5 : 350
setTimeout("FadeFunction()",num)
}
</script>

<center>
<h5><span id=DataArea2></span></h5></Center>
<button style="background-color: white; color:black" onclick="SUN">Sun</button>&nbsp;&nbsp;
<button style="background-color: white; color:black" onclick="MON">Mon</button>&nbsp;&nbsp;
<button style="background-color: white; color:black" onclick="TUE">Tue</button>&nbsp;&nbsp;
<button style="background-color: white; color:black" onclick="WED">Wed</button>&nbsp;&nbsp;
<button style="background-color: white; color:black" onclick="THU">Thu</button>&nbsp;&nbsp;
<button style="background-color: white; color:black" onclick="FRI">Fri</button>&nbsp;&nbsp;
<button style="background-color: white; color:black" onclick="SAT">Sat</button>

</center>
<br>
</br>
</BODY>

next

end sub
bar1



Δ Del Files By Extension Older Than 10 Days ucase split delete
 
How to read in text file extensions and delete older than 10 days
 
bar1
'================================================================
'L A N G U A G E 'VBScript
'
'S C R I P T N A M E 'ClearScan.VBS
'
'P U R P O S E 'To delete scanned files older than 10 days
'
'U S A G E 'Automated scripted located on server in task scheduler
'
'A U T H O R 'Eddie S. Jackson
'
'D A T E C R E A T E D '06/15/2010
'
'D A T E M O D I F I E D '
'
'D E S C R I P T I O N '
'
'C O M M E N T S '
'
'================================================================


' V A R I A B L E S
'================================================================
'FOLDER TO DELETE FILES
'[options]- any folder
strFolder = "C:\test\"

'DELETE FILES FROM SUB-FOLDERS?
'[options]- true or false
includeSubfolders = true

'FILES WITH EXTENSIONS PROVIDED IN THE LIST BELOW WILL BE DELETED
'[options]- any file type including multiple files separated by a comma, no spaces
strExtensionsToDelete = "tif"

'MAX FILE AGE IN DAYS. FILES OLDER THAN THIS WILL BE DELETED.
'[options]- any amount of days
maxAge = 10
'================================================================



'M A I N BEGIN
'================================================================
'instantiates object
set objFSO = createobject("Scripting.FileSystemObject")
'calls sub
DeleteFiles strFolder,strExtensionsToDelete, maxAge, includeSubFolders

'sub begin here
sub DeleteFiles(byval strDirectory,byval strExtensionsToDelete,byval maxAge,includeSubFolders)
on error resume next
DIM objFolder, objSubFolder, objFile
DIM strExt

set objFolder = objFSO.GetFolder(strDirectory)
for each objFile in objFolder.Files
on error resume next
for each strExt in SPLIT(UCASE(strExtensionsToDelete),",")
if RIGHT(UCASE(objFile.Path),LEN(strExt)+1) = "." & strExt then
on error resume next
IF objFile.DateLastModified < (Now - MaxAge) THEN
'wscript.echo "Deleting:" & objFile.Path & " | " & objFile.DateLastModified
objFile.Delete
exit for
END IF
end if
next
next
if includeSubFolders = true then ' Recursive delete
on error resume next
for each objSubFolder in objFolder.SubFolders
on error resume next
DeleteFiles objSubFolder.Path,strExtensionsToDelete,maxAge, includeSubFolders
next
end if
end sub
'================================================================
'M A I N END
bar1



Δ Read In Text File Extension vbscript split ucase delete
 
How to read in text file extension
 
bar1
strFolder = "C:\panel\testing"

includeSubfolders = true
strExtensionsToRead = "txt"

set objFSO = createobject("Scripting.FileSystemObject")

DeleteFiles strFolder,strExtensionsToRead, maxAge, includeSubFolders


sub DeleteFiles(byval strDirectory,byval strExtensionsToRead,byval maxAge,includeSubFolders)
DIM objFolder, objSubFolder, objFile
DIM strExt

set objFolder = objFSO.GetFolder(strDirectory)
for each objFile in objFolder.Files
for each strExt in SPLIT(UCASE(strExtensionsToRead),",")
if RIGHT(UCASE(objFile.Path),LEN(strExt)+1) = "." & strExt then
wscript.echo "Reading: " & objFile.Path
exit for
end if
next
next

end sub
bar1

bar1






Δ Monday, June 14th 2010
bar1
 

 
 
Δ OpenOffice 3.2 Silent Installation
 
How to silently install OpenOffice 3.2
       
bar1

msiexec /i "\\localhost\WinINSTALL\Packages\OpenOffice.org 3.2 (en-US)
Installation Files\openofficeorg32.msi" /qn


bar1

 

Δ Adobe Reader 9 Silent InstallationRUNAS
 
How to silently install adobe reader 9
    
bar1

start /wait C:\AdbeRdr920_en_US.exe /sAll /rs /l /msi"/qb-! /norestart ALLUSERS=1 
EULA_ACCEPT=YES SUPPRESS_APP_LAUNCH=YES"


bar1

bar1





Δ Friday, June 11th 2010
bar1
 

 
 
Δ Run One-Time Registry Key Shell Token Elevated Access Sanur RUNAS
 
How to run reg key import once and launch program with elevated credentials
 
bar1
@echo off
Title DIAGNOSTIC WINDOW
cls
IF NOT EXIST C:\PROGRA~1\YourProgram\YourProgram\TOKEN.TXT (
runas /U:ElevatedUserAccount "REGEDIT.EXE /S C:\PROGRA~1\YourProgram\YourProgram\Your_Key.reg"
| "c:\windows\system32\pw.exe" password
ECHO.>C:\PROGRA~1\YourProgram\YourProgram\TOKEN.TXT
)
runas /U:ElevatedUserAccount "C:\Program Files\YourProgram\YourProgram.exe" | "c:\windows\system32\pw.exe" password
cls
bar1

Syntax
      RUNAS [/profile] [/env] [/netonly] /user:user Program

Key
   /profile   Option to load the user's profile (registry)
   /env       Use current environment instead of user's.
   /netonly   Use the credentials specified only for remote connections.
   /user      Username in form USER@DOMAIN or DOMAIN\USER
              (USER@DOMAIN is not compatible with /netonly)
   Program    The command to execute




Δ Command Window Here
 
How to add Window Here access to context menu

opencommandwindowhere
 
 
bar1
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\Command Prompt]
@="Open Command Prompt Here (Admin)"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\Command Prompt\command]
@="Cmd.exe /k pushd %L"
bar1

bar1








Δ Thursday, June 10th 2010
bar1

 
Δ Create Day Of The Week Variable Shell for /f
 
How to get day of the week, which could be used for folder names or other logic
 
bar1
for /f %%a in ('date /t') do set DAY=%%a
bar1


 
Δ Countdown Buttons And Read In Text Messages
HTA VBScript Fade
 
How to make countdown buttons
 
bar1
<script language="vbscript">
Window.ReSizeTo 0,0
Window.moveTo -500, 0
</script>

<TITLE>&nbsp;</TITLE>
<HTA:APPLICATION ID="Sync DB"
BORDER="thin"
INNERBORDER="yes"
SCROLL="no"
CAPTION="yes"
SHOWINTASKBAR="no"
SINGLEINSTANCE="yes"
SYSMENU="no"
WINDOWSTATE="normal"

>
<STYLE> body {margin:2}
</STYLE>

<style>
body {
font-family:Verdana;
font-size: 12px;
color: black;
scrollbar-face-color:white;
scrollbar-arrow-color:black;
scrollbar-track-color:#D84419;
text-align:center;
background: lightgray;
}
#outer {
text-align:left;
border:1px solid #000000;
width:950px;
margin:auto;
}

#hdr {
height:80px;
background:white;
}

#bar {
height:25px;
background:#7B6E66;
color: #FFFFFF;
border:solid #000000;
border-width:1px 0 1px 0;
font-size: 12px;
font-weight: bold;
}

#bodyblock {
position:relative;
background: #cccccc;
color: #333333;
width:950px;
padding:0;
}

#l-col {
float:left;
background:#EDEBEA;
color: #D44519;
width:145px;
Height:400px;
}

#cont {
width:795px;
background:#ffffff;
color: #333333;
border:solid #000000;
border-width:0 0 0 1px;
text-align:left;
height:700px;
padding: 5px;
}

#ftr {
height:25px;
background:#c0c0c0;
color: #333333;
border:solid black;
border-width:1px 0 0 0;
margin:0;
}

table {
border-width: thin;
border-color: black;
border-style: groove;
font-size: 10px;
}

td {
border-width: 1px;
padding: 1px;
border-style: solid;
border-color: black;

}


</style>

</HEAD>

<BODY>
<SCRIPT Language="VBScript">
On error resume next
TASK_DELAY = 5 ''# Unit of delay. eg 10 of something
Sub Window_Onload
On error resume next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * From Win32_DesktopMonitor")
For Each objItem in colItems
intHorizontal = objItem.ScreenWidth
intVertical = objItem.ScreenHeight
Next
End Sub

sub launch(pgm)
On error resume next
set shell = createobject("wscript.shell")
shell.run pgm
end sub

Sub Window_OnLoad
On error resume next
strHTML = strHTML & "<font size=2><b><span id=CountDownTXT></span></b></font>"
DataArea.InnerHTML = strHTML
w = 400
h = 101
Return = ResizeWindow(w, h)
Return = CenterWindow(w, h)
End Sub

Function ResizeWindow(w, h)
On error resume next
width = w
height = h
window.resizeTo width, height
End Function

Function CenterWindow(w, h)
On error resume next
x = (screen.width-w)/2
y = (screen.height-h)/2
window.moveTo x, y
Call Countdown() ''# Call the countdown function
DataArea2.InnerHTML = "Download current database from network?"
End Function

sub YES
Set objShell = CreateObject("WScript.Shell")
command = "cmd /c echo.>%temp%\YES.txt"
objShell.Run command,0, False
close.self()
end sub

sub NO
Set objShell = CreateObject("WScript.Shell")
command = "cmd /c echo.>%temp%\NO.txt"
objShell.Run command,0, False
close.self()
end sub

Sub RefreshTime
CurrentTime.InnerHTML = Now
End Sub

Function CountDown() ''# Provides a count down on page in span area
On error resume next
Set oWSH = CreateObject("WScript.Shell")
oWSH.AppActivate "HTA CountDown" ' make top most app
If TASK_DELAY > 0 Then
CountDownTXT.innerhtml = TASK_DELAY
'setTimeout "CountDown()",60000 ''# Minutes ''# This is the delay factor
setTimeout "CountDown()",1000 ''# Seconds
TASK_DELAY = TASK_DELAY - 1
Else
'Msgbox "Close window " & Document.Title,vbokonly,Document.Title
Self.Close()
End If
End Function

</SCRIPT>


<script type="text/javascript">
window.onload = FadeFunction
var i = 0
function FadeFunction() {
if (i < 350) {
i=i+3
}
var d = document.body.style
d.filter = "alpha(Opacity="+i+")"
d.opacity = i/350
var num = document.all ? 5 : 350
setTimeout("FadeFunction()",num)
}
</script>


<center>
<h5><span id=DataArea2></span></h5></Center>
<button style="background-color: white; color:black" onclick="YES">Yes(<span id=DataArea></span>)</button>&nbsp;&nbsp;
<button style="background-color: white; color:black" onclick="NO">No</button>
</center>
<br>
</br>
bar1


 
Δ Bubble Sort
Shell if set /a
 
How to run a bubble sort routine
 
bar1
@echo off
set /a count=0

:loop
echo %1 > _%count%.var
set /a count=count+1
shift
if "%1" == "" goto :startSort
goto loop

:startSort
set /a total=%count%-1

:RestartSort
set /a count=0

:sortLoop
set /a next=%count%+1
call :swap %count% %next%
set /a count=count+1
if "%swapped%" == "true" goto :RestartSort
if "%count%" == "%total%" goto :output
goto :sortLoop

:swap
set /P var1="" < _%1.var
set /P var2="" < _%2.var
if /I %var1% LEQ %var2% goto noSwap
ren _%1.var _temp.var
ren _%2.var _%1.var
ren _temp.var _%2.var
set swapped=true
goto :eof

:noSwap
set swapped=
goto :eof

:output
for /L %%i in (0,1,%total%) do call :showval %%i

:cleanup
erase *.var
set next=
set offset=
set total=
set count=
set var=
set var1=
set var2=
goto :eof

:showval
type _%1.var
goto :eof
bar1



 
Δ Delete Files Older Than 14 Days
Shell For /f set /a
 
How to delete files older than 14 days
 
bar1
:: --------DELOLD.BAT----------
@echo off
SET OLDERTHAN=%1
IF NOT DEFINED OLDERTHAN GOTO SYNTAX

for /f "tokens=2" %%i in ('date /t') do set thedate=%%i

set mm=%thedate:~0,2%
set dd=%thedate:~3,2%
set yyyy=%thedate:~6,4%

set /A dd=%dd% - %OLDERTHAN%
set /A mm=%mm% + 0

if /I %dd% GTR 0 goto DONE
set /A mm=%mm% - 1
if /I %mm% GTR 0 goto ADJUSTDAY
set /A mm=12
set /A yyyy=%yyyy% - 1

:ADJUSTDAY
if %mm%==1 goto SET31
if %mm%==2 goto LEAPCHK
if %mm%==3 goto SET31
if %mm%==4 goto SET30
if %mm%==5 goto SET31
if %mm%==6 goto SET30
if %mm%==7 goto SET31
if %mm%==8 goto SET31
if %mm%==9 goto SET30
if %mm%==10 goto SET31
if %mm%==11 goto SET30
if %mm%==12 goto SET31

goto ERROR

:SET31
set /A dd=31 + %dd%
goto DONE

:SET30
set /A dd=30 + %dd%
goto DONE

:LEAPCHK
set /A tt=%yyyy% %% 4
if not %tt%==0 goto SET28
set /A tt=%yyyy% %% 100
if not %tt%==0 goto SET29
set /A tt=%yyyy% %% 400
if %tt%==0 goto SET29

:SET28
set /A dd=28 + %dd%
goto DONE

:SET29
set /A dd=29 + %dd%

:DONE
if /i %dd% LSS 10 set dd=0%dd%
if /I %mm% LSS 10 set mm=0%mm%
for %%i in (*.*) do (
set FileName=%%i
call :PROCESSFILE %%~ti
)

set mm=
set yyyy=
set dd=
set thedate=
goto EXIT

:SYNTAX
ECHO.
ECHO USAGE:
ECHO DELOLD X
ECHO Where X is the number of days previous to Today.
ECHO.
ECHO EX: "DELOLD 5" Deletes files older than 5 days.
GOTO EXIT

:PROCESSFILE
set temp=%1
set fyyyy=20%temp:~6%
set fmm=%temp:~0,2%
set fdd=%temp:~3,2%
if /I %fyyyy% GTR 2069 set fyyyy=19%temp:~6%


:: +*************************************+
:: | This is where the files are deleted |
:: | Change the ECHO command to DEL to |
:: | delete. ECHO is used for test. |
:: +*************************************+
if /I %yyyy%/%mm%/%dd% GEQ %fyyyy%/%fmm%/%fdd% (
ECHO %FileName%
)

set temp=
set fyyyy=
set fmm=
set fdd=

:EXIT
:: ----------END-DELOLD.BAT-------------
bar1


 
Δ Random PING
Shell
 
How to ping a random amount of seconds 1-99
 
bar1

set ran=%random:~-2%
ping -n %ran% 127.0.0.1>nul

bar1


 
Δ XCOPY Exclude
Shell
 
How to exclude file types with xcopy
 
bar1
echo .avi > %temp%\exclude.txt
echo .wmv >> %temp%\exclude.txt
echo .mp3 >> %temp%\exclude.txt
echo .mp4 >> %temp%\exclude.txt
echo .tmp >> %temp%\exclude.txt
echo .dat >> %temp%\exclude.txt
echo .exe >> %temp%\exclude.txt
echo .bat >> %temp%\exclude.txt
echo .cmd >> %temp%\exclude.txt
echo .vbs >> %temp%\exclude.txt

@xcopy "\\%comp2%\c$\Documents and Settings\%username%\Favorites\*.*" "%userprofile%\Favorites\" /d /i /y /c /s /e
/EXCLUDE:%temp%\exclude.txt
bar1

XCOPY source destination /A | /M /D:date /P /S /E /V /W /C /I /Q /F /L /G /H /R /T /U /K /N /O /X /Y /-Y /Z /B

[/EXCLUDE:file1[+file2][+file3]...] source Specifies the file(s) to copy. destination Specifies the location and/or name of new files.
/A Copies only files with the archive attribute set, doesn't change the attribute.

/M Copies only files with the archive attribute set, turns off the archive attribute.

/D:m-d-y Copies files changed on or after the specified date. If no date is given, copies only those files whose
source time is newer than the destination time.

/EXCLUDE:file1[+file2][+file3]...
Specifies a list of files containing strings. Each string should be in a separate line in the files. When any of the strings match any part of the absolute path of the file to be copied, that file will be excluded from being copied. For example, specifying a string like \obj\ or .obj will exclude all files underneath the directory obj or all files with the .obj extension respectively.

/P Prompts you before creating each destination file.

/S Copies directories and subdirectories except empty ones.
 
/E Copies directories and subdirectories, including empty ones. Same as /S /E. May be used to modify /T.

/V Verifies the size of each new file.

/W Prompts you to press a key before copying.

/C Continues copying even if errors occur.

/I If destination does not exist and copying more than one file, assumes that destination must be a directory.

/Q Does not display file names while copying.

/F Displays full source and destination file names while copying.

/L Displays files that would be copied.

/G Allows the copying of encrypted files to destination that does not support encryption.

/H Copies hidden and system files also.

/R Overwrites read-only files.

/T Creates directory structure, but does not copy files. Does not include empty directories or subdirectories. /T /E includes empty directories and subdirectories.

/U Copies only files that already exist in destination.

/K Copies attributes. Normal Xcopy will reset read-only attributes

/N Copies using the generated short names.

/O Copies file ownership and ACL information.

/X Copies file audit settings (implies /O).

/Y Suppresses prompting to confirm you want to overwrite an existing destination file.
/-Y Causes prompting to confirm you want to overwrite an existing destination file.

/Z Copies networked files in restartable mode.

/B Copies the Symbolic Link itself versus the target of the link.

/J Copies using unbuffered I/O. Recommended for very large files.




Δ Sending Automated Emails VBScript copyfile overwrite
 
How to send automated emails using your outlook client
 
bar1
'Sending automated emails
On Error Resume Next
'RCP = "ejackson@xxxxxx.edu"
Dim Name(3)
Name(0)="eddie.jackson@none.com"
Name(1)="mrnettek2000@yahoo.com"
Name(2)="mrnettek@gmail.com"

Const OverwriteExisting = TRUE

Set objShell = CreateObject("WScript.Shell")
comand = "cmd /c taskkill /f /im mshta.exe"
objShell.Run command,0, True

Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFile "C:\Panel\test_MAX.hta" , "c:\Panel\AdminPanelMax.txt", OverwriteExisting

Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFile "C:\Panel\test_MIN.hta" , "c:\Panel\AdminPanelMin.txt", OverwriteExisting


'This sets the attachment to be sent
Dim File(9)
File(0) = "\\ServerName\MyFolder\Tasks-Projects.xlsx"
File(1) = "c:\Panel\AdminPanelMax.txt"
File(2) = "C:\panel\favorites.docx"
File(3) = "C:\panel\ftp\data\menu1_78.html"
File(4) = "C:\panel\scriptsnippets.htm"
File(5) = "C:\panel\email.docx"
File(6) = "C:\panel\AdminPanelMin.txt"
File(7) = "C:\panel\x\csharp\CSharp MASTER DOCUMENT.docx"
File(8) = "C:\panel\WinINSTALL MASTER DOCUMENT.docx"


MSG = "Daily Archive"
SUBJ = "Daily Archive"

Set Outlook = CreateObject("Outlook.Application")
Set MAPI = Outlook.GetNameSpace("MAPI")
Set NewMail = OUtlook.CreateItem(0)
NewMail.Subject = SUBJ
NewMail.Body = MSG
'NewMail.Recipients.Add RCP

For X= 0 to (UBound(Name)-1)
NewMail.Recipients.Add Name(X)
Next

For X= 0 to (UBound(File)-1)
NewMail.Attachments.Add(file(X))
Next

NewMail.Send
bar1



Δ
PKZIPC
  
How to use pkzipc.exe
 
bar1
pkzipc -add -directories=relative -exclude="@C:\scripts\YourExclusionList.txt" "\\servername\backups\%%a\%yy%%mm%%dd%-
%HHMM%\%%c\Desktop\%yy%%mm%%dd%-%HHMM%.zip" "\\%%a\c$\docume~1\%%c\Desktop\*.*"
bar1
 

bar1






Δ Wednesday, June 8th 2010
bar1
 

 
 
Δ Tasklist Logic AND OR Shell tasklist /FI imagename
 
How to use batch logic of AND & OR
 
bar1
start /b /wait /low TASKLIST /FI "IMAGENAME eq outlook.exe" | find /i "outlook.exe" && (
start /b /wait /low taskkill /f /im outlook.exe

start "" "C:\Program Files\Microsoft Office\Office12\OUTLOOK.EXE"
) || (xcopy "c:\Documents and Settings\%username%\My Documents\Microsoft Outlook\*.pst" "C:\Documents and Settings\%username%
\archive\%COUNTER%_%DAY%\PST\")
bar1
 

bar1

 
 
 
 
 
Δ Thursday, June 3rd 2010
bar1
 



Δ HTML Button Border Color HTML HTA buton style
 
How to specify html button border color
 
bar1
<button style="background-color: #000000; border-color=black; border=0"; onclick="">
<font color="lightgray">&nbsp;c# ebook&nbsp;</font></button>

bar1
 

 

Δ HTML Input Box Color & Size HTML HTA Input type
 
How to specify input field color and size
 
bar1
<input type="text" name="Search1" size="75" style="color: black; font-family: Verdana; font-weight: bold; font-size: 18px; background-color: lightyellow;">
bar1



 
Δ Start Explorer.exe on Startupp Shell tasklist /fi  imagename
 
How to verify explorer.exe is running and launch if not; was used in the startup folder  
bar1
@ECHO OFF
Title = Checking Explorer
set var=explorer.exe
c:\windows\system32\sleep.exe 30
tasklist /FI "IMAGENAME eq %var%" 2>NUL | find /I /N "%var%">NUL
if "%ERRORLEVEL%"=="0" exit
if "%ERRORLEVEL%"=="1" (
taskkill /f /im %var%
start "" %var%
)
bar1
 

bar1




 
Δ Wednesday, June 2nd 2010
bar1



Δ Turn UAC On and Off VBScript Reg.exe ShellExecute
 
How to turn Vista/Windows UAC on and off via script
 
bar1
Dim strArg

Set objApp = CreateObject("Shell.Application")
strArg = "0"'TURN OFF UAC
'strArg = "1"'TURN ON UAC
objApp.shellExecute "cmd.exe", " /c %windir%\System32\reg.exe ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v EnableLUA /t REG_DWORD /d " & strArg & " /f", , "runas", 1
Set objApp = Nothing
bar1



Δ
Create Shortcut To A Folder
VBScript AllUsersDesktop

How to create a shortcut to a folder, in vbscript, to be used in your deployments
 
  
bar1
'How to create a desktop shortcut to a folder



On error resume next

DIM filesys, oShortCut, sWinSysDir, sAllUsersDesktopPath
SET oShell = CreateObject("WScript.Shell")
SET filesys = CreateObject("Scripting.FileSystemObject")
sAllUsersDesktopPath = oShell.SpecialFolders("AllUsersDesktop")
Set oShortCut = oShell.CreateShortcut(sAllUsersDesktopPath & "\YourShortCutName.lnk")

If filesys.FileExists("C:\YourFolderName\token.txt") THEN
On error resume next
oShortCut.TargetPath = "c:\YourFolderName"
oShortCut.Arguments = chr(34)&"c:\YourFolderName"&chr(34)
oShortCut.IconLocation = "C:\Windows\System32\shell32.dll,19"
oShortCut.Save

WScript.Quit
END IF

If NOT filesys.FileExists("C:\YourFolderName\token.txt") THEN
On error resume next
filesys.DeleteFile C:\DOCUMENTS AND SETTINGS\ALL USERS\DESKTOP\YourShortCutName.lnk", FALSE
WScript.Quit
END IF
bar1



Δ Create Shortcut To A File
VBScript FileExists AllUsersDesktop

How to create a shortcut to a file, in vbscript , to be used in your deployments
  
bar1
'How to create shortcut to a file


On error resume next
DIM filesys, oShortCut
SET oShell = CreateObject("WScript.Shell")
SET filesys = CreateObject("Scripting.FileSystemObject")
sAllUsersDesktopPath = oShell.SpecialFolders("AllUsersDesktop")
Set oShortCut = oShell.CreateShortcut(sAllUsersDesktopPath & "\YourShortcutName.lnk")


If filesys.FileExists("C:\Program Files\YourProgram.exe") THEN
oShortCut.TargetPath = chr(34)&"C:\Program Files\YourProgram.exe"&chr(34)
oShortCut.Arguments = chr(34)&"C:\Program Files\YourProgram.exe"&chr(34)
''' "C:\Windows\System32\shell32.dll,19"
oShortCut.IconLocation = "C:\Program Files\YourProgram.exe"
oShortCut.Save

WScript.Quit
END IF

If NOT filesys.FileExists("C:\Program Files\YourProgram.exe") THEN
filesys.DeleteFile "C:\DOCUMENTS AND SETTINGS\ALL USERS\DESKTOP\YourShortcutName.lnk", FALSE
WScript.Quit
END IF
bar1




Δ iTunes Silent Uninstall
WMIC

Silently uninstall full iTunes package

bar1
Here are our specs:
Uninstall iTunes silently
Uinstall QuickTime silently
Uninstall Bonjour silently
Unnstall Mobile Me silently
Uninstall Apple Update silently
Uninstall Device Support silently
Uninstall Application Support silently
Remove Shortcuts
bar1

   
bar1
wmic product where name='iTunes' call uninstall

wmic product where name='QuickTime' call uninstall
wmic product where name='Apple Software Update' call uninstall
wmic product where name='Apple Mobile Device Support' call uninstall
wmic product where name='Bonjour' call uninstall
wmic product where name='Apple Application Support' call uninstall
wmic product where name='MobileMe Control Panel' call uninstall
bar1

bar1








Δ Tuesday, June 1st 2010
bar1



Δ
iTunes Silent Installation
VBScript FileExists MSIEXEC Fileexists delete folder copyfile create folder

Silently install full iTunes package

bar1
Here are our specs:
Install iTunes silently
Install QuickTime silently
Install Bonjour silently
Install Mobile Me silently
Install Apple Update silently
Install Device Support silently
Install Application Support silently
Accept iTunes EULA
Copy customized QuickTime Settings
Stop self-healing desktop icons
Make sure all current users get settings
Make sure all new users get settings
bar1

  
bar1
On error resume next

Dim WshShell, objFSO, SystemDrive, AllUsersProgramsPath, AllUsersDesktopPath, oShortCut, oShell
SET filesys = CreateObject("Scripting.FileSystemObject")
SET oShell = CreateObject("WScript.Shell")

Set WshShell = WScript.CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")

SystemDrive = WshShell.ExpandEnvironmentStrings("%Systemdrive%")
AllUsersProgramsPath = SystemDrive & "\Documents and Settings\All Users\Start Menu\Programs"
AllUsersDesktopPath = SystemDrive & "\Documents and Settings\All Users\Desktop"


'THIS WILL BE THE CATCH FOR UNINSTALLATION
If NOT filesys.FileExists("C:\_ResourceFiles\iTunes\AppleApplicationSupport.msi") THEN WSCRIPT.QUIT

'else

'ENTER MAIN INSTALLATION ROUTINE
'INSTALLS APPLICATION SUPPORT.
WshShell.Run "c:\windows\system32\msiexec /i ""C:\_ResourceFiles\iTunes\AppleApplicationSupport.msi"" /qn /norestart", 1, True

'INSTALLS MOBILE DEVICE SUPPORT.
WshShell.Run "c:\windows\system32\msiexec /i ""C:\_ResourceFiles\iTunes\AppleMobileDeviceSupport.msi"" /qn /norestart", 1, True

'INSTALLS SOFTWARE UPDATE.
WshShell.Run "c:\windows\system32\msiexec /i ""C:\_ResourceFiles\iTunes\AppleSoftwareUpdate.msi"" /qn /norestart", 1, True

'INSTALLS BONJOUR.
WshShell.Run "c:\windows\system32\msiexec /i ""C:\_ResourceFiles\iTunes\Bonjour.msi"" /qn /norestart", 1, True

'INSTALLS MOBILE ME.
WshShell.Run "c:\windows\system32\msiexec /i ""C:\_ResourceFiles\iTunes\MobileMe.msi"" /qn /norestart", 1, True

'INSTALLS QUICKTIME.
WshShell.Run "c:\windows\system32\msiexec /i ""C:\_ResourceFiles\iTunes\QuickTime.msi"" /qn /norestart", 1, True

'REMOVES THE QUICKTIME TASKBAR ICON.
WshShell.RegWrite "HKLM\SOFTWARE\Apple Computer, Inc.\QuickTime\ActiveX\QTTaskRunFlags", 2, "REG_DWORD"

'Uses TaskKill to remove the taskbar icon right away instead of waiting for a restart.
WshShell.Run "%COMSPEC% /C TASKKILL /F /IM qttask.exe", 0, False

'INSTALLS ITUNES.
WshShell.Run "c:\windows\system32\msiexec /i ""C:\_ResourceFiles\iTunes\iTunes.msi"" DESKTOP_SHORTCUTS=0 /qn", 1, True


'CREATE QUICKTIME SHORTCUT
AllUsersDesktopPath = oShell.SpecialFolders("AllUsersDesktop")
Set oShortCut = oShell.CreateShortcut(AllUsersDesktopPath & "\QuickTime Player.lnk")
oShortCut.TargetPath = "C:\Program Files\QuickTime\QuickTimePlayer.exe"
oShortCut.IconLocation = "C:\Program Files\QuickTime\QuickTimePlayer.exe"
oShortCut.Save

SetPreferenceFiles

If objFSO.FileExists (AllUsersProgramsPath & "\iTunes\iTunes.lnk") Then
On error resume next
objFSO.CopyFile (AllUsersProgramsPath & "\iTunes\iTunes.lnk"), (AllUsersProgramsPath & "\Accessories\Entertainment\iTunes.lnk"), True
objFSO.DeleteFolder (AllUsersProgramsPath & "\iTunes"), True
End If

If objFSO.FileExists (AllUsersDesktopPath & "\iTunes.lnk") Then
On error resume next
objFSO.DeleteFile (AllUsersDesktopPath & "\iTunes.lnk"), True
End If

'CREATE ITUNE SHORTCUT
AllUsersDesktopPath = oShell.SpecialFolders("AllUsersDesktop")
Set oShortCut = oShell.CreateShortcut(AllUsersDesktopPath & "\iTunes.lnk")
oShortCut.TargetPath = "C:\Program Files\iTunes\iTunes.exe"
oShortCut.IconLocation = "C:\Program Files\iTunes\iTunes.exe"
oShortCut.Save

'COPIES A SHORTCUT TO ITUNES TO PREVENT THE MSI INSTALLER FROM BEING INVOKED FOR EACH USER - WHICH GENERATES THE DESKTOP AND START MENU ICONS AGAIN.
If objFSO.FileExists ("c:\_ResourceFiles\iTunes\iTunes.lnk") Then
On error resume next
objFSO.CopyFile ("c:\_ResourceFiles\iTunes\iTunes.lnk"), (AllUsersProgramsPath & "\Accessories\Entertainment\iTunes.lnk"), True
End If

Wscript.Quit

'SUBROUTINES ARE SHOWN BELOW
Sub SetPreferenceFiles
' Sets the needed preference files, creating the folder structure if it does not already exist.
Dim Subfolder, UserPaths

On error resume next

Set UserPaths = objFSO.GetFolder(SystemDrive & "\Documents and Settings\").Subfolders

'THIS CYCLES THROUGH EACH USER PROFILE - COPIES CUSTOMIZED ITUNES EULA AND QUICKTIME FILES TO EACH USER PROFILE
For Each Subfolder in UserPaths
On error resume next
'msgbox Subfolder
If Subfolder = (SystemDrive & "\Documents and Settings\LocalService") Then
On error resume next
'DOES NOTHING.
Else
If Subfolder = (SystemDrive & "\Documents and Settings\NetworkService") Then
On error resume next
'DOES NOTHING.
Else
If Subfolder = (SystemDrive & "\Documents and Settings\All Users") Then
On error resume next
'DOES NOTHING.
Else

'CREATES NECESSARY FOLDERS FOR CUSTOM FILES TO BE COPIED OVER
If Not objFSO.FolderExists (Subfolder & "\Local Settings\Application Data\Apple Computer") Then
On error resume next
objFSO.CreateFolder (Subfolder & "\Local Settings\Application Data\Apple Computer")
End If

If Not objFSO.FolderExists (Subfolder & "\Local Settings\Application Data\Apple Computer\iTunes") Then
On error resume next
objFSO.CreateFolder (Subfolder & "\Local Settings\Application Data\Apple Computer\iTunes")
End If

If Not objFSO.FolderExists (Subfolder & "\Local Settings\Application Data\Apple Computer\QuickTime") Then
On error resume next
objFSO.CreateFolder (Subfolder & "\Local Settings\Application Data\Apple Computer\QuickTime")
End If

If Not objFSO.FolderExists (Subfolder & "\Application Data\Apple Computer") Then
On error resume next
objFSO.CreateFolder (Subfolder & "\Application Data\Apple Computer")
End If

If Not objFSO.FolderExists (Subfolder & "\Application Data\Apple Computer\iTunes") Then
On error resume next
objFSO.CreateFolder (Subfolder & "\Application Data\Apple Computer\iTunes")
End If

If Not objFSO.FolderExists (Subfolder & "\Application Data\Apple Computer\QuickTime") Then
On error resume next
objFSO.CreateFolder (Subfolder & "\Application Data\Apple Computer\QuickTime")
End If

'THIS FILE ACCEPTS THE LICENSE AGREEMENT FOR ITUNES; ACCEPT EULA
'NOTE::THIS GETS COPIES TO ALL USER PROFILES INCLUDING THE DEFAULT USER
If objFSO.FileExists ("c:\_ResourceFiles\iTunes\localset\Application Data\Apple Computer\iTunes\iTunesPrefs.xml") Then
On error resume next
objFSO.CopyFile "c:\_ResourceFiles\iTunes\localset\Application Data\Apple Computer\iTunes\iTunesPrefs.xml", (Subfolder & "\Local Settings\Application Data\Apple Computer\iTunes\iTunesPrefs.xml"), True
End If

If objFSO.FileExists ("c:\_ResourceFiles\iTunes\appdata\Apple Computer\iTunes\iTunesPrefs.xml") Then
On error resume next
objFSO.CopyFile "c:\_ResourceFiles\iTunes\appdata\Apple Computer\iTunes\iTunesPrefs.xml", (Subfolder & "\Application Data\Apple Computer\iTunes\iTunesPrefs.xml"), True
End If

'COPIES CUSTOMIZED QUICKTIME SETTINGS
'NOTE::THIS GETS COPIES TO ALL USER PROFILES INCLUDING THE DEFAULT USER
If objFSO.FileExists ("c:\_ResourceFiles\iTunes\appdata\Apple Computer\QuickTime\QTPlayerSession.xml") Then
On error resume next
objFSO.CopyFile "c:\_ResourceFiles\iTunes\appdata\Apple Computer\QuickTime\QTPlayerSession.xml", (Subfolder & "\Application Data\Apple Computer\QuickTime\QTPlayerSession.xml"), True
End If

If objFSO.FileExists ("c:\_ResourceFiles\iTunes\localset\Application Data\Apple Computer\Quicktime\QuickTime.qtp") Then
On error resume next
objFSO.CopyFile "c:\_ResourceFiles\iTunes\localset\Application Data\Apple Computer\Quicktime\QuickTime.qtp", (Subfolder & "\Local Settings\Application Data\Apple Computer\QuickTime\QuickTime.qtp"), True
End If

End If
End If
End If
Next
End Sub
Wscript.Quit
bar1




Δ Offline Search Engine in HTA
HTML lcase inet do until

Create a searchable, offline HTA engine that queries a dictionary file and returns valid links

bar1
Here are our specs:
Create HTA to act as an offline search engine
Read site hyperlinks from a text file
Return valid links inside of a HTA
bar1


bar1
<script language="vbscript">
Window.ReSizeTo 0,0
Window.moveTo -500, 0
</script>

<!--
==================================================
Name: Search Engine
Author: Eddie Jackson
Contact: mrnettek2000@yahoo.com
Created on: 06/02/2010
Modified:
Modified by:
Description: General use offline search engine for my site
Required: Required registration of C:\windows\system32\msinet.ocx
===================================================
-->
<HTML>
<HEAD>
<TITLE>Seeker Search Engine</TITLE>
<HTA:APPLICATION ID="Search Engine"
BORDER="thick"
INNERBORDER="yes"
SCROLL="no"
CAPTION="yes"
SHOWINTASKBAR="yes"
SINGLEINSTANCE="no"
SYSMENU="yes"
WINDOWSTATE="normal"

>
<STYLE>
body {margin:2}
.style2 {
color: #2D2D24;
background: #000000;
margin-right: 0px;
}
.style3 {
color: #2D2D24;
}
.style4 {
color: #3EA73E;
}
</STYLE>
</HEAD>
<body bgcolor="000000" background="c:\panel\icons\nonematrix.gif">
<SCRIPT Language="VBScript">


On error resume next
Sub Window_Onload
Dim timerID
timerID = window.setInterval("RefreshTime", 1000) 'milliseconds
RefreshTime
On error resume next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * From Win32_DesktopMonitor")
For Each objItem in colItems
intHorizontal = objItem.ScreenWidth
intVertical = objItem.ScreenHeight
Next
End Sub

sub launch(pgm)
On error resume next
set shell = createobject("wscript.shell")
shell.run pgm
end sub
Sub Window_OnLoad
On error resume next
w = 850
h = 550
Return = ResizeWindow(w, h)
Return = CenterWindow(w, h)

End Sub

Sub RefreshTime
CurrentTime.InnerHTML = Now
End Sub

Function ResizeWindow(w, h)
On error resume next
width = w
height = h
window.resizeTo width, height
End Function

Function CenterWindow(w, h)
On error resume next
x = (screen.width-w)/2
y = (screen.height-h)/2
window.moveTo x, y
End Function


sub CSharp()
Set objShell = CreateObject("WScript.Shell")
strCommand = "C:\panel\library\source\murach_csharp_2008.pdf"
objShell.Run strCommand,9, False
end sub

sub CSharpMST()
Set objShell = CreateObject("WScript.Shell")
strCommand = chr(34)&"C:\panel\CSharp MASTER DOCUMENT.docx"&chr(34)
objShell.Run strCommand,9, False
end sub

sub WIMST()
Set objShell = CreateObject("WScript.Shell")
strCommand = chr(34)&"C:\panel\WinINSTALL MASTER DOCUMENT.docx"&chr(34)
objShell.Run strCommand,9, False
end sub

sub HTAOMATIC()
Set objShell = CreateObject("WScript.Shell")
strCommand = chr(34)&"C:\panel\x\helpers\hta_helpomatic.hta"&chr(34)
objShell.Run strCommand,9, False
end sub

sub SCRIPTOMATIC()
Set objShell = CreateObject("WScript.Shell")
strCommand = chr(34)&"C:\panel\x\helpers\ScriptomaticV2.hta"&chr(34)
objShell.Run strCommand,9, False
end sub

sub CSharp6()
Set objShell = CreateObject("WScript.Shell")
strCommand = "C:\panel\library\source\murach_csharp_2008.pdf"
objShell.Run strCommand,9, False
end sub

sub CSharp7()
Set objShell = CreateObject("WScript.Shell")
strCommand = "C:\panel\library\source\murach_csharp_2008.pdf"
objShell.Run strCommand,9, False
end sub

sub CSharp8()
Set objShell = CreateObject("WScript.Shell")
strCommand = "C:\panel\library\source\murach_csharp_2008.pdf"
objShell.Run strCommand,9, False
end sub




</SCRIPT>


<SCRIPT LANGUAGE="VBScript">
Sub funcSEARCH
on error resume next
Dim strTextToFind, strInputFile, strOutputFile, boolMatchCaseSensitive, myFSO, WebPage
Dim objFSO, objInputFile, strFoundText, strLine, objOutputFile, strFinal
Set inet = createobject("InetCtls.Inet")
Set myFSO = CreateObject("Scripting.FileSystemObject")
Set WebPage = myFSO.OpenTextFile("c:\test.txt", 2, True)'for writing
'Set WebPage = myFSO.OpenTextFile("c:\testfile.txt", 8, True)'for appending
'Set WebPage = myFSO.OpenTextFile("c:\testfile.txt", 1, True)'for reading
inet.Url = "http://eddiejackson.net/data/test.txt"
inet.RequestTimeOut = 20
strContents = inet.OpenUrl()
'msgbox strContents
'self.close()
'window.close
'window.close
'window.close
LCaseContents = LCase(strContents)
WebPage.WriteLine(LCaseContents)
WebPage.close
'SET WebPage = NOTHING
'SET myFSO = NOTHING
on error goto 0
On error resume next
DataArea.InnerHTML = ""
strFinal = ""
'DataArea.InnerHTML = strFinal
strFinal = ""

'ADD strInput = each option type here
If UserOption(0).Checked Then
'Msgbox "Option 1 was selected."
Set objShell = CreateObject("WScript.Shell")
strCommand = "iexplore.exe http://www.google.com/search?q="&Search1.value
objShell.Run strCommand,9, False
End If
If UserOption(1).Checked Then
'Msgbox "Option 1 was selected."
Set objShell = CreateObject("WScript.Shell")
strCommand = "iexplore.exe http://www.google.com/images?q="&Search1.value
objShell.Run strCommand,9, False
End If
If UserOption(2).Checked Then
'Msgbox "Option 2 was selected."
Set objShell = CreateObject("WScript.Shell")
strCommand = "iexplore.exe http://www.bing.com/search?q="&Search1.value
objShell.Run strCommand,9, False
End If
If UserOption(3).Checked Then
'Msgbox "Option 2 was selected."
Set objShell = CreateObject("WScript.Shell")
strCommand = "iexplore.exe http://www.bing.com/images/search?q="&Search1.value
objShell.Run strCommand,9, False
End If


If UserOption(4).Checked Then
'Msgbox "Option 3 was selected."
Set objShell = CreateObject("WScript.Shell")
strCommand = "iexplore.exe http://www.appdeploy.com/search/search.asp?"&"cx=014503921158165719423%3A3hy89iql-j8&cof=FORID%3A11&q="&Search1.value
objShell.Run strCommand,9, False
End If
If UserOption(5).Checked Then
'Msgbox "Option 4 was selected."
strInputFile = "C:\test.txt"
Set objFSO = CreateObject("Scripting.FilesystemObject")
Const intForReading = 1

if Search1.value <> "" then
Set objInputFile = objFSO.OpenTextFile(strInputFile, intForReading, False)
Do until objInputFile.atEndOfStream
strLine = objInputFile.ReadLine

Dim strAryWords
Dim strValue
strAryWords = Split(Search1.value, " ")
' - strAryWords is now an array
Dim i
For i = 0 to Ubound(strAryWords)
'msgbox strAryWords(i)
Searching = strAryWords(i)
LCaseSearch = LCase(Searching)
If InStr(strLine,LCaseSearch) > 0 Then
strLine = "<a href="&chr(34) & strLine &chr(34)&">"&strLine & "</a><br>"&chr(10)
'msgbox strLine
strFinal = strLine & strFinal
'msgbox strFinal
'DataArea.InnerHTML = strFinal
end if

Next

Loop

DataArea.InnerHTML = strFinal
objInputFile.Close
end if

'if Search2.value <> "" then
' Set objInputFile = objFSO.OpenTextFile(strInputFile, intForReading, False)
' Do until objInputFile.atEndOfStream
' strLine = objInputFile.ReadLine
' If InStr(strLine,Search2.value) > 0 Then
' strLine = "<a href="&chr(34) & strLine &chr(34)&">"&strLine & "</a><br>"
' 'msgbox strLine
' strFinal = strLine & strFinal
' 'msgbox strFinal
' 'DataArea.InnerHTML = strFinal
' end if
' Loop
' DataArea.InnerHTML = strFinal & "<br>"
'objInputFile.Close
'End if

'if Search3.value <> "" then
' Set objInputFile = objFSO.OpenTextFile(strInputFile, intForReading, False)
' Do until objInputFile.atEndOfStream
' strLine = objInputFile.ReadLine
' If InStr(strLine,Search3.value) > 0 Then
' strLine = "<a href="&chr(34) & strLine &chr(34)&">"&strLine & "</a><br>"
' 'msgbox strLine
' strFinal = strLine & strFinal
' 'msgbox strFinal
' 'DataArea.InnerHTML = strFinal
' end if
' Loop
' DataArea.InnerHTML = strFinal
' objInputFile.Close
'end if


Set objInputFile = Nothing
End If
If UserOption(6).Checked Then
'Msgbox "Option 5 was selected."
Set objShell = CreateObject("WScript.Shell")
strCommand = "iexplore.exe http://en.wikipedia.org/wiki/"&Search1.value
objShell.Run strCommand,9, False
End If
If UserOption(7).Checked Then
'Msgbox "Option 6 was selected."
End If
If UserOption(8).Checked Then
'Msgbox "Option 7 was selected."
Set objShell = CreateObject("WScript.Shell")
strCommand = "iexplore.exe http://en.wikipedia.org/wiki/"&Search1.value
objShell.Run strCommand,9, False
End If
If UserOption(9).Checked Then
Set objShell = CreateObject("WScript.Shell")
strCommand = "iexplore.exe http://www.youtube.com/results?search_query="&Search1.value
objShell.Run strCommand,9, False
End If
If UserOption(10).Checked Then
'Msgbox "Option 1 was selected."
Set objShell = CreateObject("WScript.Shell")
strCommand = ""
objShell.Run strCommand,9, False
End If
If UserOption(11).Checked Then
'Msgbox "Option 1 was selected."
Set objShell = CreateObject("WScript.Shell")
strCommand = ""
objShell.Run strCommand,9, False
End If
If UserOption(12).Checked Then
'Msgbox "Option 1 was selected."
Set objShell = CreateObject("WScript.Shell")
strCommand = ""
objShell.Run strCommand,9, False
End If
If UserOption(13).Checked Then
'Msgbox "Option 1 was selected."
Set objShell = CreateObject("WScript.Shell")
strCommand = ""
objShell.Run strCommand,9, False
End If
If UserOption(14).Checked Then
'Msgbox "Option 1 was selected."
Set objShell = CreateObject("WScript.Shell")
strCommand = ""
objShell.Run strCommand,9, False
End If
If UserOption(15).Checked Then
'Msgbox "Option 1 was selected."
Set objShell = CreateObject("WScript.Shell")
strCommand = ""
objShell.Run strCommand,9, False
End If
If UserOption(16).Checked Then
'Msgbox "Option 1 was selected."
Set objShell = CreateObject("WScript.Shell")
strCommand = ""
objShell.Run strCommand,9, False
End If
If UserOption(17).Checked Then
'Msgbox "Option 1 was selected."
Set objShell = CreateObject("WScript.Shell")
strCommand = ""
objShell.Run strCommand,9, False
End If
If UserOption(18).Checked Then
'Msgbox "Option 1 was selected."
Set objShell = CreateObject("WScript.Shell")
strCommand = ""
objShell.Run strCommand,9, False
End If
end sub

</SCRIPT>

<script type="text/javascript">
onload=function(){document.onkeydown=function(e){
e=(window.event)? event:e;
var k=e.keyCode;
if(k==13) {
funcSEARCH();}
if(k==27) {
DataArea.InnerHTML = "";}
}
}
</script>
<body alink=#00ff66 link=#33cc00 vlink=#00ff66>
<center>
<IMG src="c:\panel\x\hta\scanner3.gif" application="yes" width="100%" height="0%" marginwidth="0" marginheight="0" frameborder="0">
</IMG>
</center>
<center>
<table border="0"; width="100%"; align="bottom">
<tr>
<td width="0%" valign="top">
<button style="background-color: #000000; border-color=black; border=0"; onclick="CSharp" class="style4">&nbsp;c# ebook&nbsp;</button></td>
<td width="0%" valign="top">
<button style="background-color: #000000; border-color=black; border=0"; onclick="CSharpMST" class="style4">c# master</button></td>
<td width="0%" valign="top">
<button style="background-color: #000000; border-color=black; border=0"; onclick="WIMST" class="style4">wininstall master</button></td>
<td width="0%" valign="top">
<button style="background-color: #000000; border-color=black; border=0"; onclick="HTAOMATIC" class="style4">hta-o-matic</button></td>
<td width="0%" valign="top">
<button style="background-color: #000000; border-color=black; border=0"; onclick="SCRIPTOMATIC" class="style4">script-o-matic</button></td>
<td width="0%" valign="top">
<button style="background-color: #000000; border-color=black; border=0"; onclick="DROID" class="style4">&nbsp;&nbsp;droid&nbsp;&nbsp;</button></td>
<td width="0%" valign="top">
<button style="background-color: #000000; border-color=black; border=0"; onclick="IPHONE" class="style4">&nbsp;&nbsp;iphone&nbsp;&nbsp;</button></td>
<td width="0%" valign="top">
<button style="background-color: #000000; border-color=black; border=0"; onclick="FIREWALL" class="style4">&nbsp;&nbsp;firewall&nbsp;&nbsp;</button></td>
</tr>
</table>


<table border="0"; width="100%"; align="bottom">
<tr>
<td width="0%" valign="top"><font color="lightgray">&nbsp;&nbsp;&nbsp;&nbsp;</font></td>
<td width="0%" valign="top"><font color="lightgray">&nbsp;&nbsp;&nbsp;&nbsp;</font></td>
<td width="0%" valign="top"><font color="lightgray">&nbsp;&nbsp;&nbsp;&nbsp;</font></td>
<td width="0%" valign="top"><font color="lightgray">&nbsp;&nbsp;&nbsp;&nbsp;</font></td>
<td width="0%" valign="top"><font color="lightgray">&nbsp;&nbsp;&nbsp;&nbsp;</font></td>
<td width="0%" valign="top"><font color="lightgray">&nbsp;&nbsp;&nbsp;&nbsp;</font></td>
<td width="0%" valign="top"><font color="lightgray">&nbsp;&nbsp;&nbsp;&nbsp;</font></td>
<td width="0%" valign="top"><font color="lightgray">&nbsp;&nbsp;&nbsp;&nbsp;</font></td>
</tr>
</table>
<font color=#009900 style="background-color: black" size="2">
<span id="CurrentTime"></span>
<table border="0"; width="0%"; align="bottom">
<center>
<tr>
<td width="0%" valign="top"><font color="lightgray">
<input type="text" name="Search1" size="70" tabindex="0" style="color: black; font-family: Verdana; font-weight: bold; font-size: 18px; background-color: #99ff66;">
</font>
</td>
</tr>
</center>
</table>

<center>
<font color=#99ff66 size=4>
<input type="checkbox" name="UserOption" CHECKED value="1">
<font color=#99ff66 size=4 style="background-color: black">
<input type="checkbox" name="UserOption" value="2"></font>google&nbsp;&nbsp;
<input type="checkbox" name="UserOption" value="3"><font color=#99ff66 size=4 style="background-color: black">
<input type="checkbox" name="UserOption" value="4"></font>bing&nbsp;&nbsp;
<input type="checkbox" name="UserOption" value="5">appdeploy&nbsp;&nbsp;
<input type="checkbox" name="UserOption" value="6">archives&nbsp;&nbsp;
<input type="checkbox" name="UserOption" value="7">vbscript&nbsp;&nbsp;
<input type="checkbox" name="UserOption" value="8">shell&nbsp;&nbsp;
<input type="checkbox" name="UserOption" value="9">wiki&nbsp;&nbsp;
<input type="checkbox" name="UserOption" value="10">youtube&nbsp;&nbsp;
<BR>
</font>
<font color="darkgray" size=2>
<input type="radio" name="UserOption" value="11" class="style2" style="width: 9px; height: 9px"><span class="style3"> a&nbsp;&nbsp;
</span>
<input type="radio" name="UserOption" value="12" class="style2" style="width: 9px; height: 9px"><span class="style3"> b&nbsp;&nbsp;
</span>
<input type="radio" name="UserOption" value="13" class="style2" style="width: 9px; height: 9px"><span class="style3"> c&nbsp;&nbsp;
</span>
<input type="radio" name="UserOption" value="14" class="style2" style="width: 9px; height: 9px"><span class="style3"> d&nbsp;&nbsp;
</span>
<input type="radio" name="UserOption" value="15" class="style2" style="width: 9px; height: 9px"><span class="style3"> e&nbsp;&nbsp;
</span>
<input type="radio" name="UserOption" value="16" class="style2" style="width: 9px; height: 9px"><span class="style3"> f&nbsp;&nbsp;
</span>
<input type="radio" name="UserOption" value="17" class="style2" style="width: 9px; height: 9px"><span class="style3"> g&nbsp;&nbsp;
</span>
<input type="radio" name="UserOption" value="18" class="style2" style="width: 9px; height: 9px"><span class="style3"> h&nbsp;&nbsp;
</span>
<BR>
</font>

<br>
<br>
<Input id=runbutton class="button" type="button" button style="background-color: #66ff33; font-size:18" value=" Seek " name="search_button" onClick="funcSEARCH">
<br>
</center>

<SCRIPT LANGUAGE="VBScript">
On error resume next
sub launch(pgm)f
On error resume next
set shell = createobject("wscript.shell")
shell.run pgm
end sub
Sub Window_OnLoad
timerID = window.setInterval("RefreshTime", 1000) 'milliseconds
RefreshTime
Search1.Focus
w = 850
h = 550
Return = ResizeWindow(w, h)
Return = CenterWindow(w, h)

UserOption(0).checked=true
UserOption(1).checked=false
UserOption(2).checked=false
UserOption(3).checked=false
UserOption(4).checked=false
UserOption(5).checked=false
UserOption(6).checked=false
UserOption(7).checked=false
UserOption(8).checked=false
UserOption(9).checked=false
DataArea.InnerHTML = ""
Search1.value = ""

End Sub
</SCRIPT>
<center>
<h5>
<font color="lightgreen">
<font size="3">
<span id="DataArea"></span>
</font></font>
</h5>

</center>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
</BODY>
</HTML>
bar1
         
  
  
 
Δ Installing Printer Drivers
 
How to install complete printer driver list
  
bar1
Print Driver Installation Script

Here is a script that will simplify Print Driver installation. If you're familiar with RUNDLL32 PRINTUI.DLL,PrintUIEntry then
you already know that scripting with it can get pretty ugly. That is where the InstallPrn.cmd script comes in to play.
Here is an example of what a typically RUNDLL32 PRINTUI.DLL,PrintUIEntry script looks like:REM Install OEM Printer Drivers

pushd \\Server\Share\Print Drivers\
RUNDLL32 PRINTUI.DLL,PrintUIEntry /ia /m "HP LaserJet 4000 Series PCL 5e" /h "x86" /v "Windows 2000,
Windows XP and Windows Server 2003"
/f "%CD%\lj4000pcl5\hpbf221i.inf"

RUNDLL32 PRINTUI.DLL,PrintUIEntry /ia /m "HP LaserJet 4050 Series PCL 5e" /h "x86" /v "Windows 2000, Windows XP and Windows Server 2003"
 /f "%CD%\lj4050pcl5\hpbf001i.inf"

RUNDLL32 PRINTUI.DLL,PrintUIEntry /ia /m "HP LaserJet 4100 PCL 6" /h "x86" /v "Windows 2000, Windows XP and Windows Server 2003"
/f "%CD%\lj4100pcl6\hp4100p6.inf"

RUNDLL32 PRINTUI.DLL,PrintUIEntry /ia /m "HP LaserJet 4100 PS" /h "x86" /v "Windows 2000, Windows XP and Windows Server 2003" /f
"%CD%\lj4100ps\hp4100ps.inf"

popd

REM Install Native Windows Drivers
RUNDLL32 PRINTUI.DLL,PrintUIEntry /ia /m "HP LaserJet 4" /h "x86" /v "Windows 2000, Windows XP and Windows Server 2003"
/f "%systemroot%\inf\ntprint.inf"

RUNDLL32 PRINTUI.DLL,PrintUIEntry /ia /m "HP LaserJet 4M Plus" /h "x86" /v "Windows 2000, Windows XP and Windows Server 2003"
/f "%systemroot%\inf\ntprint.inf"

RUNDLL32 PRINTUI.DLL,PrintUIEntry /ia /m "HP LaserJet 4 Plus" /h "x86" /v "Windows 2000, Windows XP and Windows Server 2003"
/f "%systemroot%\inf\ntprint.inf"

RUNDLL32 PRINTUI.DLL,PrintUIEntry /ia /m "HP LaserJet 5" /h "x86" /v "Windows 2000, Windows XP and Windows Server 2003"
/f "%systemroot%\inf\ntprint.inf"

RUNDLL32 PRINTUI.DLL,PrintUIEntry /ia /m "HP LaserJet 5M" /h "x86" /v "Windows 2000, Windows XP and Windows Server 2003"
/f "%systemroot%\inf\ntprint.inf"

RUNDLL32 PRINTUI.DLL,PrintUIEntry /ia /m "HP LaserJet 5Si" /h "x86" /v "Windows 2000, Windows XP and Windows Server 2003"
/f "%systemroot%\inf\ntprint.inf"

RUNDLL32 PRINTUI.DLL,PrintUIEntry /ia /m "HP LaserJet 5Si/5Si MX PS" /h "x86" /v "Windows 2000, Windows XP and Windows Server 2003"
/f "%systemroot%\inf\ntprint.inf"

RUNDLL32 PRINTUI.DLL,PrintUIEntry /ia /m "HP LaserJet 5Si MX" /h "x86" /v "Windows 2000, Windows XP and Windows Server 2003"
/f "%systemroot%\inf\ntprint.inf"

RUNDLL32 PRINTUI.DLL,PrintUIEntry /ia /m "HP LaserJet 8000 Series PS" /h "x86" /v "Windows 2000, Windows XP and Windows Server 2003" /f
"%systemroot%\inf\ntprint.inf"



PrinterInstallation.cmd:
REM Install OEM Printer Drivers
pushd %~dp0
call InstallPrn.cmd "HP LaserJet 4000 Series PCL 5e" "lj4000pcl5\hpbf221i.inf"
call InstallPrn.cmd "HP LaserJet 4050 Series PCL 5e" "lj4050pcl5\hpbf001i.inf"
call InstallPrn.cmd "HP LaserJet 4100 PCL 6" "lj4100pcl6\hp4100p6.inf"
call InstallPrn.cmd "HP LaserJet 4100 PS" "lj4100ps\hp4100ps.inf"
REM Install Native Windows Drivers
call InstallPrn.cmd "HP LaserJet 4"
call InstallPrn.cmd "HP LaserJet 4M Plus"
call InstallPrn.cmd "HP LaserJet 4 Plus"
call InstallPrn.cmd "HP LaserJet 5"
call InstallPrn.cmd "HP LaserJet 5M"
call InstallPrn.cmd "HP LaserJet 5Si"
call InstallPrn.cmd "HP LaserJet 5Si/5Si MX PS"
call InstallPrn.cmd "HP LaserJet 5Si MX"
call InstallPrn.cmd "HP LaserJet 8000 Series PS"
popd


The second script is definately much easier to read and maintain. The InstallPrn.cmd script does require that you have
your OEM printer drivers organized on a network share. The path that you specify to the OEM Printer's .inf file will be
relative. This can easily be changed if you want to specify the full path but to defeats the purpose of tightly controlling
OEM printer drivers and versions. If your organization has implemented (or soon will) any type of change control consider
setting up a centralized repository for print drivers.

Now for the script. Items that are bolded need to be modified before the script can be used.

InstallPrn.cmd:TITLE Install Print Driver %~1

:: Usage:
:: InstallPrn.cmd "<Printer Name>" "<Path to INF>"
::
:: If the <Path to INF> is blank "%systemroot%\inf\ntprint.inf" is used
::
:: Examples:
:: InstallPrn.cmd "HP LaserJet 4100 PS" "lj4100ps\hp4100ps.inf"
:: InstallPrn.cmd "HP Laserjet 4"
@echo off
setlocal
REM Set the location for your printer repository as all <Path to INF> lcoations
:: are relative to this path
set PrintDriverRoot=\\My Server\share\Print Drivers
set Printer_Name=%~1
set INF_File=%~2
If "|%Printer_Name%|" == "||" goto no_Printer:
If "|%INF_File%|" == "||" (
set PrintDriverPath=%systemroot%\inf\ntprint.inf
set Install_Msg=Install Native Print Driver: %Printer_Name%
) else (
pushd %PrintDriverRoot%
set pushd_flag=true
set PrintDriverPath=%CD%\%INF_File%
set Install_Msg=Install OEM Print Driver : %Printer_Name%
)
if exist "%PrintDriverPath%" (
echo %Install_Msg%
RUNDLL32 PRINTUI.DLL,PrintUIEntry /ia /m "%Printer_Name%" /v "Windows 2000, Windows XP and Windows Server
2003" /f "%PrintDriverPath%"
) else (
echo Print Driver %Printer_Name% was not install. Could not find file: %PrintDriverPath%
)
goto end:
:no_Printer
echo No Printer Name was specified
:end
if /i "%pushd_flag%" == "true" popd
endlocal
@echo on
bar1
 
bar1


..About

..I'm a Computer
..
Systems Engineer

..
Living and loving life
........................................


..
Author

...