Δ
Wednesday, December 29th, 2010
Δ
Build HTML from a Shell Script
How to use a shell script to build a HTML document, useful
for those shell scripters our there that would like to view output in HTML
format.
Shell Script:
@echo off title Retrieve System Information by Eddie Jackson color 0a
:BEGIN ::script version used in output set strVAR=v1.0
if
"%1"=="" goto :Local set strSrv=%1 goto :Main
:LOCAL set
strSrv=%computername%
:MAIN echo Retrieving System Information for
"%strSrv%" echo please wait... echo.
::DEFINE FILE FOR HTML OUTPUT
set docOutput=%strSrv%-Info.htm
::DELETE FILE IF IT ALREADY EXISTS if
exist %docOutput% del %docOutput% >NUL ::delete error log if it previously
exists if exist %strSrv%-Error.log del %strSrv%-Error.log >NUL
::BUILD
A SHELL HTML FILE. echo ^<html^> >> %docOutput% echo ^<body^> >>
%docOutput% echo ^<H3^>^<Font Face=Verdana Color=Blue^>^<P
align=Center^>%strSrv%^<BR^> >>%docOutput% echo Retrieve System
Information^</Font^>^</H3^>^ >>%docOutput% echo by Eddie
Jackson^</Font^>^</H4^>^</P^> >>%docOutput% echo ^<HR^> >>%docOutput% echo
^</html^> >> %docOutput% echo ^</body^> >> %docOutput%
::VERIFY
CONNECTIVITY AND WMI COMPATIBILITY wmic /node:"%strSrv%" os list brief 1>NUL
2>> %strSrv%-Error.log if errorlevel=0 goto :GETDATA echo ^<Font
Color=Red^>^<B^> OOPS!! ^</P^>>> %docOutput% echo Can't verify connectivity
to or WMI compatibility with "%strSrv%" ^</P^> >> %docOutput% for /f
"tokens=*" %%i in (%strSrv%-Error.log) do @echo %%i ^<br^> >>%docOutput% echo
^</Font^>^</B^> ^</P^> >> %docOutput% goto :Cleanup
:GETDATA
::START RETRIEVING INFORMATION. echo memory... echo ^<Font
Color=Green^>^<H3^>^<B^>^<I^>^<BR^>Memory^</Font^>^</H3^>^</B^>^</I^> >>
%docOutput% wmic /node:"%strSrv%" /append:"%docOutput%" memlogical get
AvailableVirtualMemory, TotalVirtualMemory, TotalPhysicalMemory,
TotalPageFileSpace /format:htable.xsl >NUL ping -n 3 127.0.0.1>nul
echo pagefile... echo ^<Font
Color=Green^>^<H3^>^<B^>^<I^>^<BR^>PageFile^</Font^>^</H3^>^</B^>^</I^> >>
%docOutput% wmic /node:"%strSrv%" /append:"%docOutput%" pagefileset get name,
initialsize, maximumsize /format:htable.xsl >NUL wmic /node:"%strSrv%"
/append:"%docOutput%" pagefile get Caption, CurrentUsage, PeakUsage, InstallDate
/format:htable.xsl >NUL ping -n 3 127.0.0.1>nul
echo logical drives...
echo ^<Font Color=Green^>^<H3^>^<B^>^<I^>^<BR^>Drive
Information^</Font^>^</H3^>^</B^>^</I^> >> %docOutput% wmic /node:"%strSrv%"
/append:"%docOutput%" logicaldisk where drivetype=3 get name, size, freespace,
compressed, filesystem /format:htable.xsl >NUL ping -n 3 127.0.0.1>nul
echo process... echo ^<Font
Color=Green^>^<H3^>^<B^>^<I^>^<BR^>Processes^</Font^>^</H3^>^</B^>^</I^> >>
%docOutput% wmic /node:"%strSrv%" /append:"%docOutput%" process list brief
/format:htable.xsl >NUL ping -n 3 127.0.0.1>nul
echo service...
echo ^<Font
Color=Green^>^<H3^>^<B^>^<I^>^<BR^>Services^</Font^>^</H3^>^</B^>^</I^> >>
%docOutput% wmic /node:"%strSrv%" /append:"%docOutput%" service where
state="Running" get pathname, state, startmode, displayname, processid
/format:htable.xsl >NUL ping -n 3 127.0.0.1>nul
echo ip address...
echo ^<Font Color=Green^>^<H3^>^<B^>^<I^>^<BR^>IP
Info^</Font^>^</H3^>^</B^>^</I^> >> %docOutput% wmic /node:"%strSrv%"
/append:"%docOutput%" NICCONFIG WHERE IPEnabled=true GET IPAddress
/format:htable.xsl >NUL ping -n 3 127.0.0.1>nul
echo. echo Results
have been returned. Opening HTML Document now... ping -n 3 127.0.0.1>nul
:FOOTER echo ^<I^>^<Font Size=-1^>^<BR^>^<BR^>%strVAR% >>%docOutput%
date /t >>%docOutput% time /t >>%docOutput% echo --- COMPUTERNAME:
%computername% >>%docOutput% echo --- USER DOMAIN: %userdomain% >>%docOutput%
echo --- LOGON SERVER: %logonserver% >>%docOutput% echo --- USERNAME:
%username% ^</I^>>>%docOutput%
if exist %strSrv%-Error.log del /Q
%strSrv%-Error.log >NUL
start "" %docOutput%
set strSrv= set
docOutput= set strVAR=
::EOF exit /b 0
|
Δ
Clear Event Logs
How to clear the event logs without a tracer log entry.
WSF/VBScript:
<?XML?> <job> <!--
================================================================ Save or
rename this file extension as ClearEvt.wsf
Use "ClearEvt /?" or "CScript
ClearEvt.wsf /?" for help.
================================================================= -->
<runtime> <description> This script silently clears the Windows Event Log
files. By Mark Fairpo. </description> <unnamed name="LogName"
helpstring="Name of each event log to clear. Default is Application, Security
and System." many="true" required="false" /> <named name="Quiet
or /Q" helpstring="If specified, error messages will not be displayed, but
returns ERRORLEVEL 1." type="simple" required="false" /> </runtime>
<object id="WshShell" progid="WScript.Shell"/> <script language="VBScript">
<![CDATA[ Const conComputer = "." On Error Resume Next Set colArgs =
WScript.Arguments.Unnamed If colArgs.Count = 0 Then ' Use default
arguments if none supplied Set colArgs = CreateObject("Scripting.Dictionary")
colArgs.Add "Application", "" colArgs.Add "System", "" colArgs.Add
"Security", "" End If Set objWMIService =
GetObject("winmgmts:{impersonationLevel=Impersonate,(Security,Backup)}!\\" & _
conComputer & "\root\cimv2") If Err Then ErrHandler "Could not connect to
Windows Management Instrumentation (WMI). " & _ Err.Description & ". WMI Core
may not be installed" For Each strLogName In colArgs Set colLogFiles =
objWMIService.ExecQuery _ ("SELECT * FROM Win32_NTEventLogFile WHERE
LogFileName='" & strLogName & "'") If Err Then ErrHandler "Could not query
the '" & strLogName & "' event log. " & Err.Description If colLogFiles.Count
> 0 Then For Each objLogFile In colLogFiles errClearEvt = 99
errClearEvt = objLogFile.ClearEventLog() Select Case errClearEvt Case 0
' Success Case 5 ErrHandler "Access was denied to clear '" & strLogName &
"' event log" Case 8 ErrHandler "Privilege missing to clear '" &
strLogName & "' event log" Case 21 ErrHandler "Invalid parameter to clear
'" & strLogName & "' event log" Case 99 ErrHandler "Failed to clear '" &
strLogName & "' event log. " & Err.Description Case Else ErrHandler
"Failed to clear '" & strLogName & "' event log. Error " & errClearEvt End
Select Next Else ErrHandler "Event log '" & strLogName & "' not found"
End If Next
Sub ErrHandler(strErrDescription) If Not
(WScript.Arguments.Named.Exists("QUIET") Or WScript.Arguments.Named.Exists("Q"))
Then If WshShell.Popup(strErrDescription & ". See usage information?", 10,
WScript.ScriptName & _ " (10 Seconds)", vbExclamation + vbYesNo +
vbDefaultButton2) = vbYes Then WScript.Arguments.ShowUsage End If End
If WScript.Quit 1 End Sub ]]> </script> </job>
|
Δ
Alphabetize/Sort a Text File
How to sort a specified text file.
Shell:
::alphabetize your file ::usage: sortdata.cmd NameOfYourTextFile.txt
:BEGIN @echo off setlocal if {%1} EQU {} goto SYNTAX if not exist %1
goto SYNTAX set file=%1 set file="%file:"=%" set work=%TEMP%\%~nx1
set work="%work:"=%" set work=%work:\\=\% sort %file% /O %work% del /f
/q %file% for /f "Tokens=*" %%s in ('type %work%') do set record=%%s&call
:output endlocal goto :EOF
:SYNTAX @echo
*************************** @echo Syntax: SortDup Input_File @echo
*************************** endlocal goto :EOF :output if not
defined prev_rec goto write if "%record%" EQU "%prev_rec%" goto :EOF
:write @echo %record%>>%file% set prev_rec=%record%
:EOF exit/ b
0
|
Δ
Tuesday, December 28th, 2010
Δ
Passing Credentials in Windows 7
How to pass elevated credentials inside scripts, thus
changing the security context
It used to be easy to pass credentials in XP, a ton of utilities worked just
fine. It's not like that anymore in Windows 7; Microsoft has patched all the
holes. Microsoft's Runas.exe works in the console, that's if you access the
console directly and type the password in, however it's useless inside of
scripts (unless using the dreadful sendkey approach). Sanur used to worked
great in XP (I must have used it a 1000 times), now it justs errors out in
Windows 7. So, with a little creative scripting and combing a few utils to
perform a single function, you can now pass credentials iin Windows 7. How I did
it using cpau.exe & hstart.exe (you can use just cpau.exe with the -hide option;
I like using hstart because of its many other options).
Script:
rem elevated script rem disabling a nic
rem creates our command file
-----------------------
echo %windir%\system32\netsh.exe interface set interface "Local Area Connection"
DISABLED>"%temp%\Disable_NIC.cmd"
echo %windir%\system32\netsh.exe
interface set interface "Wireless Network Connection"
DISABLED>>"%temp%\Disable_NIC.cmd"
echo %windir%\system32\netsh.exe
interface set interface "Local Area Connection* 19"
DISABLED>>"%temp%\Disable_NIC.cmd"
echo %windir%\system32\netsh.exe
interface set interface "Local Area Connection 2"
DISABLED>>"%temp%\Disable_NIC.cmd"
echo %windir%\system32\netsh.exe
interface set interface "Local Area Connection 3"
DISABLED>>"%temp%\Disable_NIC.cmd" echo exit /b 0>>"%temp%\Disable_NIC.cmd"
rem -------------------------------------------------------
rem launches our command file with elevated credentials "%temp%\CPAU.exe"
-u %computername%\administrator -p PASSWORD -ex "%temp%\hstart.exe /noconsole
%temp%\Disable_NIC.cmd" -LWP
|
Δ
How To Dim The Screen
How to dim the screen with HTA, great for an attention grabber.
You must download and register the dynwrap.dll on your computer for this to work
in ontop mode, otherwise it will still dim, it just won't stay ontop of other
windows if a new window takes focus. You will also need the capturemation
software. With all that said, it really is a nice effect.
HTA/VBScript:
<script language="vbscript"> on error resume next window.moveTo 0-11, 0-15
window.resizeTo (screen.width+11), (screen.height+16) Set oWSH =
CreateObject("WScript.Shell") oWSH.AppActivate "DIM" ' make top most app
'set current directory strCurrentDirectory = oWSH.CurrentDirectory
oWSH.Run "%comspec% /c copy /y /v "&chr(34)&strCurrentDirectory
&"\cpau.exe"&chr(34)&" %temp%\",0, true oWSH.Run "%comspec% /c copy /y /v
"&chr(34)&strCurrentDirectory &"\hstart.exe"&chr(34)&" %temp%\",0, true
'elevated access 'enabled'elevated apply registry key - not needed for xp
oWSH.Run "%comspec% /c echo %windir%\regedit.exe /s
%temp%\sndrec32.reg>%temp%\registry.cmd",0,true oWSH.Run "%comspec% /c
%temp%\CPAU.exe -u %computername%\administrator -p PASSWORD -ex
"&chr(34)&"%temp%\hstart.exe /noconsole %temp%\registry.cmd"&chr(34)&"
-LWP",0,true oWSH.Run "%temp%\sndrec32.exe /play /close
%temp%\dim.wav",0,false 'oWSH.Run "%comspec% /c %windir%\system32\ping.exe -n
1 127.0.0.1",0,true
'capturemation software oWSH.Run "%comspec% /c
%temp%\cap.exe /full /quality=100 /file=%temp%\dim.jpg",0,true oWSH.Run
"%comspec% /c copy /v /y %temp%\dim.jpg
"&chr(34)&strCurrentDirectory&chr(34),0,true 'oWSH.Run "%comspec% /c
%windir%\system32\ping.exe -n 1 127.0.0.1",0,true </script>
<html>
<head> <style> body { background-color:#000000; } </style> </head>
<body bgcolor="black"> </body> </html>
<!--
======================================================= Name: DIMDISPLAY
Author: Eddie Jackson Contact: MrNetTek2000@yahoo.com Created on:
12/23/2010 Modified: Modified by: Description: DIM Splash Screen
It works in seconds and minutes
======================================================= -->
<head>
<title>DIM</title>
<HTA:APPLICATION ID="DIM" APPLICATIONNAME="DIM"
BORDER="thin" INNERBORDER="no" SCROLL="no" SELECTION="no"
CAPTION="no" SHOWINTASKBAR="no" SINGLEINSTANCE="yes" SYSMENU="no"
WINDOWSTATE="normal"
>
</head>
<script type="text/vbscript"
language="vbscript"> on error resume next Set oWSH =
CreateObject("WScript.Shell") oWSH.AppActivate "DIM" ' make top most app
const bontop=true
sub setontop 'use global constant bontop const
SWP_NOSIZE=&H1 const SWP_NOMOVE=&H2 const HWND_TOPMOST=-1 const
HWND_NOTOPMOST=-2 const lpClassName="HTML Application Host Window Class"
dim odw, hwnd set odw=createobject("DynamicWrapper") odw.register
"user32.dll", "FindWindowA", "i=ss", "f=s", "r=l" odw.register "user32.dll",
"SetWindowPos", "i=lllllll", "f=s", "r=l" hwnd=odw.FindWindowA(lpClassName,
window.document.title)
if bontop then on error resume next
odw.SetWindowPos hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOMOVE
else odw.SetWindowPos hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE Or
SWP_NOMOVE end if
set odw=nothing
end sub </script>
<SCRIPT Language="VBScript"> on error resume next setontop()
Set oWSH = CreateObject("WScript.Shell") oWSH.AppActivate "DIM" ' make top
most app 'TASK_DELAY = 60 ''# Unit of delay. eg 10 of something
Sub Window_OnLoad on error resume next setontop() Set oWSH =
CreateObject("WScript.Shell") oWSH.AppActivate "DIM" ' make top most app
strComputer = "." End Sub
</SCRIPT>
<body bgcolor="black">
<!-- Include the VML behavior --> <style>v\: * {
behavior:url(#default#VML);display:inline-block }</style>
<!-- Declare
the VML namespace --> <xml:namespace ns="urn:schemas-microsoft-com:vml"
prefix="v" /> <v:image style="height:674pt;width:1080pt" src="dim.jpg"
blacklevel="-9999f"/> </body> </html>
|
Δ
Tuesday, December 21st, 2010
Δ
Beep in VBScript
How to create a beep sound vbscript, useful for alerts.
VBScript
Set objWSH = WScript.CreateObject("WScript.Shell")
objWSH.Run
"%comspec% /c echo " & Chr(07), 0, True
|
Δ
Talking Scripts
How to make your scripts talk, useful for alerts and chat
scripts.
VBScript
Dim message, sapi message = "ATTENTION, I AM TALKING!" Set
sapi=CreateObject("sapi.spvoice") sapi.volume = 100 sapi.Speak message
'.Pause = pause speaking '.resume = resume after pause '.Rate =
speed at which voice speaks '.Voice = you can use set and a voice value to
change the voice (if multiple exist on machine) '.Volume = volume of voice
(not system volume, just voice) '.WaitUntilDone = wait until done -
|
Δ
Monday, December 20th, 2010
Δ
Disable NICs
How to disbale wireless and wired NICs, useful for
controlling the spread of a virus.
Command
%windir%\system32\netsh.exe interface set interface "Local Area Connection"
DISABLED
VBScript
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
':: SCRIPT LANGUAGE: VBScript ':: SCRIPT NAME: VirusAlert.vbs ':: PURPOSE:
To be used to ':: CREATION DATE: 12/23/2010 ':: LAST MODIFIED: '::
DIRECTIONS: Send to client workstation ':: AUTHOR: Eddie Jackson '::
EMAIL: MrNetTek2000@yahoo.com
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'MEDIA TYPES '1-Wired '2-Wireless
'DEVCON.EXE UTILITY
'Device Console Help: 'devcon.exe [-r] [-m:\\<machine>] <command> [<arg>...]
'-r if specified will reboot machine after command is complete, if needed.
'<machine> is name of target machine. '<command> is command to perform (see
below). '<arg>... is one or more arguments if required by command. 'For
help on a specific command, type: devcon.exe help <command> '
'disable-->Disable devices that match the specific hardware or instance ID.
Const HKEY_LOCAL_MACHINE = &H80000002 Public oWShell, oReg Set oWShell
= Wscript.CreateObject("Wscript.Shell") strComputer = "."
Set
objShell = CreateObject("WScript.Shell") strCurrentDirectory =
objShell.CurrentDirectory
Set
oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer &
"\root\default:StdRegProv")
'WINDOWS 7 strKeyPath =
"SYSTEM\CurrentControlSet\Control\Network" EnumeratingSubkeys0
HKEY_LOCAL_MACHINE, strKeyPath'win7 all network cards
'WINDOWS XP
strKeyPath = "SYSTEM\CurrentControlSet\Control\Network" EnumeratingSubkeys1
HKEY_LOCAL_MACHINE, strKeyPath'disables wireless
'WINDOWS XP
strKeyPath = "SYSTEM\CurrentControlSet\Control\Network" EnumeratingSubkeys2
HKEY_LOCAL_MACHINE, strKeyPath'disables wired
'copy file to system32
for secondary launch from setup.cmd if neccessary objShell.Run "%comspec% /c
copy /v /y "& chr(34)& strCurrentDirectory & "\disable_NIC.vbs"&chr(34) &"
\\%computername%\c$\windows\system32\",0,true objShell.Run "%comspec% /c copy
/v /y "& chr(34)& strCurrentDirectory & "\devcon_32.exe"&chr(34) &"
\\%computername%\c$\windows\system32\",0,true 'exit successfully
WScript.Quit(0)
'ALL NETWORK CARDS ( => DefaultNameIndex=0 ) - Windows 7
Sub EnumeratingSubkeys0(HKEY_LOCAL_MACHINE, strKeyPath)
'reg keys from
windows 7 machine
'[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Network\{4D36E972-E325-11CE-BFC1-08002BE10318}\{CEE04A62-F4C1-4DDA-8269-C64DAF96133D}\Connection]
'"DefaultNameResourceId"=dword:0000070b '"DefaultNameIndex"=dword:00000000
'"Name"="Local Area Connection"
'"PnpInstanceID"="PCI\\VEN_8086&DEV_10F5&SUBSYS_30DC103C&REV_03\\3&33FD14CA&0&C8"
'example 'E:\test>devcon_32.exe disable
""@"PCI\VEN_8086&DEV_10F5&SUBSYS_30DC103C&REV_03\3&33FD14CA&0&C8"
'PCI\VEN_8086&DEV_10F5&SUBSYS_30DC103C&REV_03\3&33FD14CA&0&C8: Disabled '1
device(s) disabled.
'working 'oWShell.Run "%comspec% /c
devcon_32.exe disable ""@" &
"PCI\VEN_8086&DEV_10F5&SUBSYS_30DC103C&REV_03\3&33FD14CA&0&C8" & """" ,0,false
'DISABLE ALL NICS oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath,
arrSubkeys
If IsArray(arrSubkeys) Then On error resume next For
Each strSubkey In arrSubkeys On error resume next If Instr(subkey,
"{4D36E972") = 0 Then EnumeratingSubkeys0 HKEY_LOCAL_MACHINE,strKeyPath & "\"
& strSubkey End If If subkey <> "PnpInstanceID" Then On error resume
next strValueName = "DefaultNameIndex" oReg.GetDWORDValue
HKEY_LOCAL_MACHINE,strKeyPath & "\" & subkey & "\" & "Connection"
,strValueName,dwvalue
If dwvalue = 0 Then On error resume next
strValueName = "PnpInstanceID" oReg.GetStringValue
HKEY_LOCAL_MACHINE,strKeyPath & "\" & subkey & "\" &
"Connection",strValueName,strValue oWShell.Run "%comspec% /c
%temp%\devcon_32.exe disable ""@" & strValue & """" ,0,false WScript.Sleep
3000 oWShell.Run "%comspec% /c %temp%\devcon_32.exe disable
""@"&"PCI\VEN_8086&DEV_10DE&SUBSYS_3034103C&REV_02\3&42FFD25&0&C8"& """"
,0,false WScript.Sleep 3000 End If End If Next End If
oWShell.Run "%comspec% /c %temp%\devcon_32.exe disable ""@" &
"PCI\VEN_8086&DEV_10DE&SUBSYS_3034103C&REV_02\3&42FFD25&0&C8" & """" ,0,false
WScript.Sleep 3000 End Sub
'DISABLE WIRED NETWORK CARDS ( =>
MEDIASUBTYPE=1 ) - Windows XP Sub EnumeratingSubkeys2(HKEY_LOCAL_MACHINE,
strKeyPath)
oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubkeys
If IsArray(arrSubkeys) Then On error resume next For Each strSubkey
In arrSubkeys On error resume next If Instr(subkey, "{4D36E972") = 0 Then
EnumeratingSubkeys2 HKEY_LOCAL_MACHINE,strKeyPath & "\" & strSubkey End If
If subkey <> "Descriptions" Then On error resume next strValueName =
"MediaSubType" oReg.GetDWORDValue HKEY_LOCAL_MACHINE,strKeyPath & "\" &
subkey & "\" & "Connection" ,strValueName,dwvalue
If dwvalue = 1 Then
On error resume next strValueName = "PnpInstanceID" oReg.GetStringValue
HKEY_LOCAL_MACHINE,_ strKeyPath & "\" & subkey & "\" & "Connection"
,strValueName,strValue oWShell.Run "%comspec% /c %temp%\devcon_32.exe disable
""@" & strValue & """" ,0,false WScript.Sleep 3000 End If End If
Next End If End Sub
'DISABLE WIRELESS NETWORK CARDS ( =>
MEDIASUBTYPE=2 ) - Windows XP Sub EnumeratingSubkeys1(HKEY_LOCAL_MACHINE,
strKeyPath)
oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubkeys
If IsArray(arrSubkeys) Then On error resume next For Each strSubkey
In arrSubkeys On error resume next If Instr(subkey, "{4D36E972") = 0 Then
EnumeratingSubkeys1 HKEY_LOCAL_MACHINE,strKeyPath & "\" & strSubkey End If
If subkey <> "Descriptions" Then On error resume next strValueName =
"MediaSubType" oReg.GetDWORDValue HKEY_LOCAL_MACHINE,_ strKeyPath & "\" &
subkey & "\" & "Connection" ,strValueName,dwvalue
If dwvalue = 2 Then
On error resume next strValueName = "PnpInstanceID" oReg.GetStringValue
HKEY_LOCAL_MACHINE,strKeyPath & "\" & subkey & "\" & "Connection"
,strValueName,strValue oWShell.Run "%comspec% /c %temp%\devcon_32.exe disable
""@" & strValue & """" ,0,false WScript.Sleep 3000 End If End If
Next End If End Sub
|
Δ
Thursday, December 16th, 2010
Δ
Install VLC Player
How to deploy VLC 0.9.9, 1.1.4, 1.1.5 to your enterprise
Shell script install
:check-ver setlocal for /f %%x in ('fvi
"%ProgramFiles%\VideoLAN\VLC\vlc.exe"') do set FV=%%x if "%FV%"=="1.1.5.0" (
rem latest version at 12-14-2010 goto end ) endlocal if exist
"%ProgramFiles%\VideoLAN\VLC\vlc.exe" %comspec% /c MsiExec.exe
/X{3F927A23-9913-4BBF-B70D-566327589B72} /qn if exist
"%ProgramFiles%\VideoLAN\VLC\vlc.exe" %comspec% /c
"%ProgramFiles%\VideoLAN\VLC\uninstall.exe" /S goto INSTALLVLC goto end
:INSTALLVLC REM Install VLC Player 1.1.5 from default distribution
package rem %comspec% /c "\\SERVERNAME\software\Installs\VLC\vlc
1.1.4\vlc-1.1.4-win32.exe" /l=1033 /S /ncrc %comspec% /c
"\\SERVERNAME\software\Installs\VLC\vlc 1.1.5\vlc-1.1.5-win32.exe" /l=1033 /S
/ncrc goto end
:end
|
VBScript install
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
':: E L I T E S O L U T I O N S ':: SCRIPT LANGUAGE: VBScript '::
SCRIPT NAME: VLC_Install.vbs ':: PURPOSE: To be used to install VLC Player
1.1.5 ':: CREATION DATE: 12/17/2010 ':: LAST MODIFIED: ':: DIRECTIONS:
Send to client workstation ':: AUTHOR: Eddie Jackson ':: EMAIL:
MrNetTek2000@yahoo.com
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'VARIABLES on error resume next
Dim filesys, strComputer,
OSDetect, objWMIService, colInstances, sUser, strUser, objShell, Install,
Update, DELICON, Windows7_OS, XP_OS Dim SDMCache, AppPath, wshShell,
SetupFilesPath, SetupPath, Update1, Update2, Update3, Update4 Dim objAccount,
objSubkey, strKeyPath, strSubPath, strValue, REGEDIT Const HKEY_LOCAL_MACHINE
= &H80000002
AppPath = "VLC\VLC_1.1.5"
Set filesys =
CreateObject("Scripting.FileSystemObject") Set objShell =
CreateObject("Wscript.Shell") Set wshShell =
WScript.CreateObject("WScript.Shell")
'PRE-SETUP COMMANDS on error
resume next Set objShell = CreateObject("Wscript.Shell") objShell.Run
"%comspec% /c %windir%\system32\taskkill.exe /f /im cmd.exe",0,True
objShell.Run "%comspec% /c %windir%\system32\taskkill.exe /f /im
SetupFiles.exe",0,True objShell.Run "%comspec% /c
%windir%\system32\taskkill.exe /f /im mshta.exe",0,True objShell.Run
"%comspec% /c %windir%\system32\taskkill.exe /f /im vlc.exe",0,True
'POLICY DISABLED 'FilterFile = "c:\Program Files\YourProgram\foo.exe" 'If
filesys.FileExists(FilterFile) THEN 'WScript.Quit(0) 'End if
'TASKKILLS PRE-INSTALLATION COMMANDS 'KILLS CURRENTLY RUNNING MSIEXEC.EXE
objShell.Run "%comspec% /c %windir%\SYSTEM32\TASKKILL.EXE /F /IM
msiexec.exe",0,True
'KILLS CURRENTLY RUNNING setup.exe objShell.Run
"%comspec% /c %windir%\SYSTEM32\TASKKILL.EXE /F /IM setup.exe",0,True
'SET WORKSTATION NAME - PRIMARY METHOD strComputer = "."
'SET
WORKSTATION NAME - SECONDARY METHOD if strComputer = "" then on error
resume next Set wshNetwork = WScript.CreateObject( "WScript.Network" )
strComputer = wshNetwork.ComputerName end if
'SET WORKSTATION NAME -
TERTIARY METHOD if strComputer = "" then on error resume next
strComputer = wshShell.ExpandEnvironmentStrings( "%COMPUTERNAME%" ) end if
'ENABLED'PRIMARY OS DETECTION Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20
Set objWMIService = GetObject(
"winmgmts://" & strComputer & "/root/CIMV2" ) Set colInstances =
objWMIService.ExecQuery( "SELECT * FROM Win32_OperatingSystem", "WQL",
wbemFlagReturnImmediately + wbemFlagForwardOnly )
For Each objInstance In
colInstances on error resume next 'msgbox objInstance.Caption OSDetect
= objInstance.Caption Next
OSDetect = trim(OSDetect) 'msgbox
OSDetect
if OSDetect = "Microsoft Windows XP Professional" then XP()
if OSDetect = "Microsoft Windows XP" then XP() if OSDetect = "Microsoft
Windows XP Home" then XP() if OSDetect = "Microsoft Windows Vista Ultimate"
then Seven() if OSDetect = "Microsoft Windows Vista Premium" then Seven()
if OSDetect = "Microsoft Windows Vista Home" then Seven() if OSDetect =
"Microsoft Windows Vista Basic" then Seven() if OSDetect = "Microsoft Windows
7 Enterprise" then Seven() if OSDetect = "Microsoft Windows 7 Enterprise
Edition" then Seven() if OSDetect = "Microsoft Windows 7 Ultimate" then
Seven() if OSDetect = "Microsoft Windows 7 Ultimate Edition" then Seven()
if OSDetect = "Microsoft Windows Server 2003 Standard" then XP() if OSDetect
= "Microsoft Windows Server 2008 Standard" then Seven() if OSDetect =
"Microsoft Windows Server 2008 Standard Edition" then Seven() if OSDetect =
"Microsoft Windows Server 2008 Enterprise" then Seven() if OSDetect =
"Microsoft Windows Server 2008 Enterprise Edition" then Seven() if OSDetect
<> "Microsoft Windows Server 2008 Enterprise" then XP() WScript.Quit(0)
'SETS UP SECONDARY OS DETECTION IF NEEDED Windows7_OS = "C:\Users\Public"
XP_OS = "C:\Documents and Settings"
'DISABLED'SECONDARY DETECTION LOGIC
'''##If filesys.FolderExists(Windows7_OS) then Seven() '''##If
filesys.FolderExists(XP_OS) then XP()
'DISABLED'TERTIARY DETECTION
LOGIC '''##if OSDetect <> "Microsoft Windows 7 Enterprise" then XP() 'END
OS DETECTION
'W I N D O W S X P Sub XP on error resume next
'LAUNCH CORRECT SPLASH SCREEN - separate logic provides granular control
STARTCOUNTER =
"C:\Progra~1\LANDesk\LDClient\sdmcache\APPS\"&AppPath&"\STARTCOUNTER.hta"
'primary logic - to be used for LANDesk installations If
filesys.FileExists(STARTCOUNTER) THEN 'msgbox "Counter does exist in LANDesk
path" Err.Number = objShell.Run (STARTCOUNTER,9,True) WScript.Sleep
2000'timing ErrorCode0 = Err.Number end if
'secondary logic - to be
used for normal installations outside of LANDesk If NOT
filesys.FileExists(STARTCOUNTER) THEN 'msgbox "Counter does not exist in
LANDesk path" Err.Number = objShell.Run ("STARTCOUNTER.hta",9,True)
WScript.Sleep 2000'timing ErrorCode0 = Err.Number 'msgbox "step0 " &
ErrorCode0 'WScript.Quit(0) end if
'LAUNCH CORRECT SPLASH
SCREEN - separate logic provides granular control LANDeskLogo =
"C:\Progra~1\LANDesk\LDClient\sdmcache\APPS\"&AppPath&"\LANDesk.hta" 'primary
logic - to be used for LANDesk installations If
filesys.FileExists(LANDeskLogo) THEN 'msgbox "LANDesk Logo does exist in
LANDesk path" Err.Number = objShell.Run (LANDeskLogo,9,False)
WScript.Sleep 2000 ErrorCode0 = Err.Number end if
'secondary logic
- to be used for normal installations outside of LANDesk If NOT
filesys.FileExists(LANDeskLogo) THEN 'msgbox "LANDesk Logo does not exist in
LANDesk path" Err.Number = objShell.Run ("Kaplan.HTA",9,False)
WScript.Sleep 2000 ErrorCode0 = Err.Number 'msgbox "step0 " & ErrorCode0
'WScript.Quit(0) end if
'SET WORKING DIRECTORY AND LAUNCH MESSAGE
COMMAND FILE 'WINDOWS XP NORMAL PATH SDMCachePath =
"C:\Progra~1\LANDesk\LDClient\sdmcache\APPS\" & AppPath If
filesys.FolderExists(SDMCachePath) then on error resume next
objShell.CurrentDirectory = SDMCachePath End if
'ENABLED'TEMPORARILY
TURNS OFF AUTOMATIC UPDATES on error resume next Set objShell =
CreateObject("WScript.Shell") objShell.Run "%comspec% /c
%windir%\system32\net.exe stop wuauserv",0,True WScript.Sleep 2000
'ENABLED'PRE-INSTALLATION MAKE DIRECTORY objShell.Run "%comspec% /c md " &
chr(34) & "C:\progra~1\VideoLAN" & chr(34),0,True WScript.Sleep 1000
'ENABLED'PRE-INSTALLATION SET FOLDER PERMISSIONS objShell.Run
"%windir%\system32\cacls.exe" & " " & chr(34) & "C:\Progra~1\VideoLAN" & chr(34)
& " " & "/e /g everyone:f",0,True WScript.Sleep 1000
'ENABLED'PRE-INSTALLATION MAKE DIRECTORY objShell.Run "%comspec% /c md " &
chr(34) & "C:\progra~1\VideoLAN\VLC" & chr(34),0,True WScript.Sleep 1000
'ENABLED'PRE-INSTALLATION SET FOLDER PERMISSIONS objShell.Run
"%windir%\system32\cacls.exe" & " " & chr(34) & "C:\Progra~1\VideoLAN\VLC" &
chr(34) & " " & "/e /g everyone:f",0,True WScript.Sleep 1000
'ENABLED'REMOVE APPLICATION - ACTS A REPAIR COMPONENT on error resume next
Remove = "%comspec% /c %windir%\system32\msiexec.exe
/x{C8991EC9-847A-49DD-9C30-7D794CDE858C} /QN /norestart /L* %temp%\VLC0.9.9.log"
'msgbox Remove Err.Number = objShell.Run (Remove,0,True) WScript.Sleep
5000'timing
Remove2 = "%comspec% /c
C:\Progra~1\VideoLAN\VLC\uninstall.exe /S /NCRC" 'msgbox Remove Err.Number
= objShell.Run (Remove2,0,True) WScript.Sleep 5000'timing 'ErrorCode3 =
Err.Number 'msgbox "step3 " & ErrorCode3 'WScript.Quit(0)
'ENABLED'INSTALLS APPLICATION WITH SILENT SWITCHES on error resume next
'primary logic - used for LANDesk installation - separate logic provides
granular control SetupPath =
"C:\Progra~1\LANDesk\LDClient\sdmcache\APPS\"&AppPath&"\vlc-1.1.5-win32.exe"
If filesys.FileExists(SetupPath) THEN on error resume next Set objShell =
CreateObject("WScript.Shell") 'msgbox "Setup.msi does exist in LANDesk path"
Install = "%comspec% /c "& chr(34) & SetupPath & chr(34) & " /l=1033 /S /ncrc"
Err.Number = objShell.Run (Install,0,True) WScript.Sleep 5000'wait for
installation ErrorCode4 = Err.Number 'msgbox "step4 " & ErrorCode4 end
if
'secondary logic - used for normal installation outside of LANDesk
If NOT filesys.FileExists(SetupPath) THEN on error resume next Set
objShell = CreateObject("WScript.Shell") 'objShell.Run "%comspec% /c copy /y
/v VLCMediaPlayer0.9.9.msi \\%computername%\c$\windows\system32",0,True
'msgbox "Setup.msi does not exist in landesk path" 'WScript.Quit(0)
'performs silent installation except for a post setup splash screen Install =
"%comspec% /c "& chr(34) & "vlc-1.1.5-win32.exe" & chr(34) & " /l=1033 /S /ncrc"
WScript.Sleep 5000'wait for installation Err.Number = objShell.Run
(Install,0,True) ErrorCode4 = Err.Number end if
'ENABLED'TURNS ON
AUTOMATIC UPDATES on error resume next Set objShell =
CreateObject("Wscript.Shell") objShell.Run "%comspec% /c
%windir%\SYSTEM32\net.exe start wuauserv",0,False'STARTS THE WINDOWS UPDATE
SERVICE WScript.Sleep 2000 'msgbox "step9 " & ErrorCode9
'ENABLED'POST-INSTALLATION TASKKILLS objShell.Run "%comspec% /c
%windir%\system32\taskkill.exe /f /im mshta.exe",0,False'KILLS SPLASH SCREEN and
Logo Screen WScript.Sleep 1000 '''objShell.Run "%comspec% /c
%windir%\system32\taskkill.exe /f /im cmd.exe",0,True'KILLS ANY CMD.EXE
'ENABLED'HANDLES FINAL ERRORCODE on error resume next if ErrorCode4 = 3010
then ErrorCode4 = 0'REBOOT if ErrorCode4 = 3509 then ErrorCode4 = 0'SUCCESS
if ErrorCode4 = 1602 then ErrorCode4 = 0'REPAIR if ErrorCode4 = "" then
ErrorCode4 = 0'EMPTY
'TESTING DIAGNOSTIC 'msgbox "End Time: " &
TIME
'QUIT WITH ERROR CODE WScript.Quit(ErrorCode4) WScript.Quit(0)
End Sub
'W I N D O W S 7 Sub SEVEN() on error resume next
'secondary logic - to be used for normal installations outside of LANDesk
''If NOT filesys.FileExists(EXTRACTSPLASH) THEN ''objShell.Run
"splash.exe",9,True ''end if
''WScript.Sleep 1000'timing
'LAUNCH CORRECT SPLASH SCREEN - separate logic provides granular control
STARTCOUNTER =
"C:\progra~2\LANDesk\LDClient\sdmcache\APPS\"&AppPath&"\STARTCOUNTER.hta"
'primary logic - to be used for LANDesk installations If
filesys.FileExists(STARTCOUNTER) THEN 'msgbox "Counter does exist in LANDesk
path" Err.Number = objShell.Run (STARTCOUNTER,9,True) WScript.Sleep
2000'timing ErrorCode0 = Err.Number end if
'secondary logic - to be
used for normal installations outside of LANDesk If NOT
filesys.FileExists(STARTCOUNTER) THEN 'msgbox "Counter does not exist in
LANDesk path" Err.Number = objShell.Run ("STARTCOUNTER.hta",9,True)
WScript.Sleep 2000'timing ErrorCode0 = Err.Number 'msgbox "step0 " &
ErrorCode0 'WScript.Quit(0) end if
'LAUNCH CORRECT SPLASH
SCREEN - separate logic provides granular control LANDeskLogo =
"C:\progra~2\LANDesk\LDClient\sdmcache\APPS\"&AppPath&"\LANDesk.hta" 'primary
logic - to be used for LANDesk installations If
filesys.FileExists(LANDeskLogo) THEN 'msgbox "LANDesk Logo does exist in
LANDesk path" Err.Number = objShell.Run (LANDeskLogo,9,False)
WScript.Sleep 2000 ErrorCode0 = Err.Number end if
'secondary logic
- to be used for normal installations outside of LANDesk If NOT
filesys.FileExists(LANDeskLogo) THEN 'msgbox "LANDesk Logo does not exist in
LANDesk path" Err.Number = objShell.Run ("Kaplan.HTA",9,False)
WScript.Sleep 2000 ErrorCode0 = Err.Number 'msgbox "step0 " & ErrorCode0
'WScript.Quit(0) end if
'SET WORKING DIRECTORY AND LAUNCH MESSAGE
COMMAND FILE 'WINDOWS XP NORMAL PATH SDMCachePath =
"C:\progra~2\LANDesk\LDClient\sdmcache\APPS\" & AppPath If
filesys.FolderExists(SDMCachePath) then on error resume next
objShell.CurrentDirectory = SDMCachePath End if
'ENABLED'TEMPORARILY
TURNS OFF AUTOMATIC UPDATES on error resume next Set objShell =
CreateObject("WScript.Shell") objShell.Run "%comspec% /c
%windir%\system32\net.exe stop wuauserv",0,True WScript.Sleep 2000
'ENABLED'PRE-INSTALLATION MAKE DIRECTORY objShell.Run "%comspec% /c md " &
chr(34) & "C:\progra~2\VideoLAN" & chr(34),0,True WScript.Sleep 1000
'ENABLED'PRE-INSTALLATION SET FOLDER PERMISSIONS objShell.Run
"%windir%\system32\cacls.exe" & " " & chr(34) & "C:\progra~2\VideoLAN" & chr(34)
& " " & "/e /g everyone:f",0,True WScript.Sleep 1000
'ENABLED'PRE-INSTALLATION MAKE DIRECTORY objShell.Run "%comspec% /c md " &
chr(34) & "C:\progra~2\VideoLAN\VLC" & chr(34),0,True WScript.Sleep 1000
'ENABLED'PRE-INSTALLATION SET FOLDER PERMISSIONS objShell.Run
"%windir%\system32\cacls.exe" & " " & chr(34) & "C:\progra~2\VideoLAN\VLC" &
chr(34) & " " & "/e /g everyone:f",0,True WScript.Sleep 1000
'ENABLED'REMOVE APPLICATION - ACTS A REPAIR COMPONENT on error resume next
Remove1 = "%comspec% /c %windir%\system32\msiexec.exe
/x{C8991EC9-847A-49DD-9C30-7D794CDE858C} /QN /norestart /L* %temp%\VLC0.9.9.log"
'msgbox Remove Err.Number = objShell.Run (Remove1,0,True) WScript.Sleep
5000'timing
Remove2 = "%comspec% /c
C:\Progra~2\VideoLAN\VLC\uninstall.exe /S /NCRC" 'msgbox Remove Err.Number
= objShell.Run (Remove2,0,True) WScript.Sleep 5000'timing
'ErrorCode3 = Err.Number 'msgbox "step3 " & ErrorCode3 'WScript.Quit(0)
'ENABLED'INSTALLS APPLICATION WITH SILENT SWITCHES on error resume next
'primary logic - used for LANDesk installation - separate logic provides
granular control SetupPath =
"C:\Progra~2\LANDesk\LDClient\sdmcache\APPS\"&AppPath&"\vlc-1.1.5-win32.exe"
If filesys.FileExists(SetupPath) THEN on error resume next Set objShell =
CreateObject("WScript.Shell") 'msgbox "Setup.msi does exist in LANDesk path"
Install = "%comspec% /c "& chr(34) & SetupPath & chr(34) & " /l=1033 /S /ncrc"
Err.Number = objShell.Run (Install,0,True) WScript.Sleep 5000'wait for
installation ErrorCode4 = Err.Number 'msgbox "step4 " & ErrorCode4 end
if
'secondary logic - used for normal installation outside of LANDesk
If NOT filesys.FileExists(SetupPath) THEN on error resume next Set
objShell = CreateObject("WScript.Shell") 'objShell.Run "%comspec% /c copy /y
/v VLCMediaPlayer0.9.9.msi \\%computername%\c$\windows\system32",0,True
'msgbox "Setup.msi does not exist in landesk path" 'WScript.Quit(0)
'performs silent installation except for a post setup splash screen Install =
"%comspec% /c "& chr(34) & "vlc-1.1.5-win32.exe" & chr(34) & " /l=1033 /S /ncrc"
WScript.Sleep 5000'wait for installation Err.Number = objShell.Run
(Install,0,True) ErrorCode4 = Err.Number end if
'ENABLED'TURNS ON
AUTOMATIC UPDATES on error resume next Set objShell =
CreateObject("Wscript.Shell") objShell.Run "%comspec% /c
%windir%\SYSTEM32\net.exe start wuauserv",0,False'STARTS THE WINDOWS UPDATE
SERVICE WScript.Sleep 2000 'msgbox "step9 " & ErrorCode9
'ENABLED'POST-INSTALLATION TASKKILLS objShell.Run "%comspec% /c
%windir%\system32\taskkill.exe /f /im mshta.exe",0,False'KILLS SPLASH SCREEN and
Logo Screen WScript.Sleep 1000 '''objShell.Run "%comspec% /c
%windir%\system32\taskkill.exe /f /im cmd.exe",0,True'KILLS ANY CMD.EXE
'DISABLED'POST-INSTALLATION DELETE FILES '''objShell.Run "%comspec% /c del /q
msg.txt",0,True'DELETES MSG TEXT FILE
'ENABLED'HANDLES FINAL ERRORCODE
on error resume next if ErrorCode4 = 3010 then ErrorCode4 = 0'REBOOT if
ErrorCode4 = 3509 then ErrorCode4 = 0'SUCCESS if ErrorCode4 = 1602 then
ErrorCode4 = 0'REPAIR if ErrorCode4 = "" then ErrorCode4 = 0'EMPTY
'TESTING DIAGNOSTIC 'msgbox "End Time: " & TIME
'QUIT WITH ERROR
CODE WScript.Quit(ErrorCode4) WScript.Quit(0) End Sub
|
Δ
Wednesday, December 8th, 2010
Δ
Live Person Enterprise Deployment
How to deploy Live Person 8.4.0.0 to your enterprise
VBScript:
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
':: E L I T E S O L U T I O N S ':: SCRIPT LANGUAGE: VBScript
':: SCRIPT NAME: LivePerson_Install.vbs ':: PURPOSE: To be used to install
Live Person ':: CREATION DATE: 12/09/2010 ':: LAST MODIFIED: '::
DIRECTIONS: Send to client workstation ':: AUTHOR: Eddie Jackson '::
EMAIL: MrNetTek2000@yahoo.com
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'VARIABLES on error resume next
Dim filesys, strComputer,
OSDetect, objWMIService, colInstances, sUser, strUser, objShell, Install,
Update, DELICON, Windows7_OS, XP_OS Dim SDMCache, AppPath, wshShell,
SetupFilesPath, SetupPath, Update1, Update2, Update3, Update4 Dim objAccount,
objSubkey, strKeyPath, strSubPath, strValue, REGEDIT Const HKEY_LOCAL_MACHINE
= &H80000002
AppPath = "Microsoft\LivePerson"
Set filesys =
CreateObject("Scripting.FileSystemObject") Set objShell =
CreateObject("Wscript.Shell") Set wshShell =
WScript.CreateObject("WScript.Shell")
'PRE-SETUP COMMANDS on error
resume next Set objShell = CreateObject("Wscript.Shell") objShell.Run
"%comspec% /c %windir%\system32\taskkill.exe /f /im cmd.exe",0,True
objShell.Run "%comspec% /c %windir%\system32\taskkill.exe /f /im
SetupFiles.exe",0,True objShell.Run "%comspec% /c
%windir%\system32\taskkill.exe /f /im mshta.exe",0,True objShell.Run
"%comspec% /c %windir%\system32\taskkill.exe /f /im hc.exe",0,True
'POLICY DISABLED 'FilterFile = "c:\Program Files\YourProgram\foo.exe" 'If
filesys.FileExists(FilterFile) THEN 'WScript.Quit(0) 'End if
'TASKKILLS PRE-INSTALLATION COMMANDS 'KILLS CURRENTLY RUNNING MSIEXEC.EXE
objShell.Run "%comspec% /c %windir%\SYSTEM32\TASKKILL.EXE /F /IM
msiexec.exe",0,True
'KILLS CURRENTLY RUNNING setup.exe objShell.Run
"%comspec% /c %windir%\SYSTEM32\TASKKILL.EXE /F /IM setup.exe",0,True
'SET WORKSTATION NAME - PRIMARY METHOD strComputer = "."
'SET
WORKSTATION NAME - SECONDARY METHOD if strComputer = "" then on error
resume next Set wshNetwork = WScript.CreateObject( "WScript.Network" )
strComputer = wshNetwork.ComputerName end if
'SET WORKSTATION NAME -
TERTIARY METHOD if strComputer = "" then on error resume next
strComputer = wshShell.ExpandEnvironmentStrings( "%COMPUTERNAME%" ) end if
'ENABLED'PRIMARY OS DETECTION Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20
Set objWMIService = GetObject(
"winmgmts://" & strComputer & "/root/CIMV2" ) Set colInstances =
objWMIService.ExecQuery( "SELECT * FROM Win32_OperatingSystem", "WQL",
wbemFlagReturnImmediately + wbemFlagForwardOnly )
For Each objInstance In
colInstances on error resume next 'msgbox objInstance.Caption OSDetect
= objInstance.Caption Next
OSDetect = trim(OSDetect) 'msgbox
OSDetect
if OSDetect = "Microsoft Windows XP Professional" then XP()
if OSDetect = "Microsoft Windows XP" then XP() if OSDetect = "Microsoft
Windows XP Home" then XP() if OSDetect = "Microsoft Windows Vista Ultimate"
then Seven() if OSDetect = "Microsoft Windows Vista Premium" then Seven()
if OSDetect = "Microsoft Windows Vista Home" then Seven() if OSDetect =
"Microsoft Windows Vista Basic" then Seven() if OSDetect = "Microsoft Windows
7 Enterprise" then Seven() if OSDetect = "Microsoft Windows 7 Enterprise
Edition" then Seven() if OSDetect = "Microsoft Windows 7 Ultimate" then
Seven() if OSDetect = "Microsoft Windows 7 Ultimate Edition" then Seven()
if OSDetect = "Microsoft Windows Server 2003 Standard" then XP() if OSDetect
= "Microsoft Windows Server 2008 Standard" then Seven() if OSDetect =
"Microsoft Windows Server 2008 Standard Edition" then Seven() if OSDetect =
"Microsoft Windows Server 2008 Enterprise" then Seven() if OSDetect =
"Microsoft Windows Server 2008 Enterprise Edition" then Seven() if OSDetect
<> "Microsoft Windows Server 2008 Enterprise" then XP() WScript.Quit(0)
'SETS UP SECONDARY OS DETECTION IF NEEDED Windows7_OS = "C:\Users\Public"
XP_OS = "C:\Documents and Settings"
'W I N D O W S X P Sub XP
on error resume next
'EXTRACT SPLASH SCREEN & COUNTER FILES 'primary
logic - to be used for LANDesk installations EXTRACTSPLASH =
"C:\Progra~1\LANDesk\LDClient\sdmcache\APPS\"&AppPath&"\splash.exe" If
filesys.FileExists(EXTRACTSPLASH) THEN objShell.Run EXTRACTSPLASH,9,True
end if
'secondary logic - to be used for normal installations outside of
LANDesk If NOT filesys.FileExists(EXTRACTSPLASH) THEN objShell.Run
"splash.exe",9,True end if
WScript.Sleep 1000'timing
'LAUNCH
CORRECT SPLASH SCREEN - separate logic provides granular control STARTCOUNTER
= "C:\Progra~1\LANDesk\LDClient\sdmcache\APPS\"&AppPath&"\STARTCOUNTER.hta"
'primary logic - to be used for LANDesk installations If
filesys.FileExists(STARTCOUNTER) THEN 'msgbox "Counter does exist in LANDesk
path" Err.Number = objShell.Run (STARTCOUNTER,9,True) WScript.Sleep
2000'timing ErrorCode0 = Err.Number end if
'secondary logic - to be
used for normal installations outside of LANDesk If NOT
filesys.FileExists(STARTCOUNTER) THEN 'msgbox "Counter does not exist in
LANDesk path" Err.Number = objShell.Run ("STARTCOUNTER.hta",9,True)
WScript.Sleep 2000'timing ErrorCode0 = Err.Number 'msgbox "step0 " &
ErrorCode0 'WScript.Quit(0) end if
'LAUNCH CORRECT SPLASH
SCREEN - separate logic provides granular control LANDeskLogo =
"C:\Progra~1\LANDesk\LDClient\sdmcache\APPS\"&AppPath&"\LANDesk.hta" 'primary
logic - to be used for LANDesk installations If
filesys.FileExists(LANDeskLogo) THEN 'msgbox "LANDesk Logo does exist in
LANDesk path" Err.Number = objShell.Run (LANDeskLogo,9,False)
WScript.Sleep 2000 ErrorCode0 = Err.Number end if
'secondary logic
- to be used for normal installations outside of LANDesk If NOT
filesys.FileExists(LANDeskLogo) THEN 'msgbox "LANDesk Logo does not exist in
LANDesk path" Err.Number = objShell.Run ("Kaplan.HTA",9,False)
WScript.Sleep 2000 ErrorCode0 = Err.Number 'msgbox "step0 " & ErrorCode0
'WScript.Quit(0) end if
'SET WORKING DIRECTORY AND LAUNCH MESSAGE
COMMAND FILE 'WINDOWS XP NORMAL PATH SDMCachePath =
"C:\Progra~1\LANDesk\LDClient\sdmcache\APPS\" & AppPath If
filesys.FolderExists(SDMCachePath) then on error resume next
objShell.CurrentDirectory = SDMCachePath End if
'ENABLED'TEMPORARILY
TURNS OFF AUTOMATIC UPDATES on error resume next Set objShell =
CreateObject("WScript.Shell") objShell.Run "%comspec% /c
%windir%\system32\net.exe stop wuauserv",0,True WScript.Sleep 2000
'ENABLED'PRE-INSTALLATION MAKE DIRECTORY objShell.Run "%comspec% /c md " &
chr(34) & "C:\progra~1\LivePerson" & chr(34),0,True
'ENABLED'PRE-INSTALLATION SET FOLDER PERMISSIONS objShell.Run
"%windir%\system32\cacls.exe" & " " & chr(34) & "C:\Progra~1\LivePerson" &
chr(34) & " " & "/e /g everyone:f",0,True
'ENABLED'INSTALLS APPLICATION
WITH SILENT SWITCHES on error resume next
'primary logic - used for
LANDesk installation - separate logic provides granular control SetupPath =
"C:\Progra~1\LANDesk\LDClient\sdmcache\APPS\"&AppPath&"\lpsetup.exe" If
filesys.FileExists(SetupPath) THEN on error resume next Set objShell =
CreateObject("WScript.Shell") 'msgbox "Setup.msi does exist in LANDesk path"
WScript.Sleep 2000 Install = "%comspec% /c " & SetupPath & " /S"
Err.Number = objShell.Run (Install,0,False) WScript.Sleep 4000'wait for
installation ErrorCode4 = Err.Number 'msgbox "step4 " & ErrorCode4 end
if
'secondary logic - used for normal installation outside of LANDesk
If NOT filesys.FileExists(SetupPath) THEN on error resume next Set
objShell = CreateObject("WScript.Shell") 'msgbox "Setup.msi does not exist in
landesk path" WScript.Sleep 2000 'msgbox "exiting" 'WScript.Quit(0)
'performs silent installation except for a post setup splash screen Install =
"%comspec% /c lpsetup.exe /S" WScript.Sleep 4000'wait for installation
Err.Number = objShell.Run (Install,0,False) ErrorCode4 = Err.Number end if
'TASKKILL THE HC.EXE POST SETUP SPLASH SCREEN TO MAKE THE INSTALLATION
COMPLETELY SILENT objShell.Run "%comspec% /c %windir%\system32\taskkill.exe
/f /im hc.exe",0,True WScript.Sleep 1000 objShell.Run "%comspec% /c
%windir%\system32\taskkill.exe /f /im hc.exe",0,True WScript.Sleep 1000
objShell.Run "%comspec% /c %windir%\system32\taskkill.exe /f /im hc.exe",0,True
WScript.Sleep 1000 objShell.Run "%comspec% /c %windir%\system32\taskkill.exe
/f /im hc.exe",0,True WScript.Sleep 1000 objShell.Run "%comspec% /c
%windir%\system32\taskkill.exe /f /im hc.exe",0,True WScript.Sleep 1000
objShell.Run "%comspec% /c %windir%\system32\taskkill.exe /f /im hc.exe",0,True
WScript.Sleep 1000 objShell.Run "%comspec% /c %windir%\system32\taskkill.exe
/f /im hc.exe",0,True WScript.Sleep 1000 objShell.Run "%comspec% /c
%windir%\system32\taskkill.exe /f /im hc.exe",0,True WScript.Sleep 1000
objShell.Run "%comspec% /c %windir%\system32\taskkill.exe /f /im hc.exe",0,True
WScript.Sleep 1000 objShell.Run "%comspec% /c %windir%\system32\taskkill.exe
/f /im hc.exe",0,True WScript.Sleep 1000 objShell.Run "%comspec% /c
%windir%\system32\taskkill.exe /f /im hc.exe",0,True WScript.Sleep 1000
objShell.Run "%comspec% /c %windir%\system32\taskkill.exe /f /im hc.exe",0,True
'ENABLED'POST-INSTALLATION ADD DESKTOP ICON TO ALL USERS on error resume
next DELICON = "%comspec% /c del /q " & chr(34) &
"%userprofile%\Desktop\LivePerson.lnk"& chr(34) Err.Number = objShell.Run
(DELICON,0,True) WScript.Sleep 1000
ADDICON = "%comspec% /c copy /y /v
" & chr(34)&"%ALLUSERSPROFILE%\Start
Menu\Programs\LivePerson\LivePerson.lnk"&chr(34) & " " &
chr(34)&"%ALLUSERSPROFILE%\Desktop"&chr(34) Err.Number = objShell.Run
(ADDICON,0,False) WScript.Sleep 1000 '''ErrorCode7 = Err.Number 'msgbox
"step7 " & ErrorCode7 'WScript.Quit(0)
'ENABLED'TURNS ON AUTOMATIC
UPDATES on error resume next Set objShell = CreateObject("Wscript.Shell")
objShell.Run "%comspec% /c %windir%\SYSTEM32\net.exe start
wuauserv",0,False'STARTS THE WINDOWS UPDATE SERVICE WScript.Sleep 2000
'msgbox "step9 " & ErrorCode9
'ENABLED'POST-INSTALLATION TASKKILLS
objShell.Run "%comspec% /c %windir%\system32\taskkill.exe /f /im
mshta.exe",0,True'KILLS SPLASH SCREEN and Logo Screen '''objShell.Run
"%comspec% /c %windir%\system32\taskkill.exe /f /im cmd.exe",0,True'KILLS ANY
CMD.EXE
'DISABLED'POST-INSTALLATION DELETE FILES '''objShell.Run
"%comspec% /c del /q msg.txt",0,True'DELETES MSG TEXT FILE
'ENABLED'HANDLES FINAL ERRORCODE on error resume next if ErrorCode4 = 3010
then ErrorCode4 = 0'REBOOT if ErrorCode4 = 1602 then ErrorCode4 = 0'REPAIR
if ErrorCode4 = "" then ErrorCode4 = 0'EMPTY
'TESTING DIAGNOSTIC
'msgbox "End Time: " & TIME
'QUIT WITH ERROR CODE
WScript.Quit(ErrorCode4) WScript.Quit(0) End Sub
'W I N D O
W S 7 Sub SEVEN() on error resume next
'EXTRACT SPLASH SCREEN &
COUNTER FILES 'primary logic - to be used for LANDesk installations
EXTRACTSPLASH =
"C:\Progra~2\LANDesk\LDClient\sdmcache\APPS\"&AppPath&"\splash.exe" If
filesys.FileExists(EXTRACTSPLASH) THEN objShell.Run EXTRACTSPLASH,9,True
end if
'secondary logic - to be used for normal installations outside of
LANDesk If NOT filesys.FileExists(EXTRACTSPLASH) THEN objShell.Run
"splash.exe",9,True end if
WScript.Sleep 1000'timing
'LAUNCH
CORRECT SPLASH SCREEN - separate logic provides granular control STARTCOUNTER
= "C:\Progra~2\LANDesk\LDClient\sdmcache\APPS\"&AppPath&"\STARTCOUNTER.hta"
'primary logic - to be used for LANDesk installations If
filesys.FileExists(STARTCOUNTER) THEN 'msgbox "Counter does exist in LANDesk
path" Err.Number = objShell.Run (STARTCOUNTER,9,True) WScript.Sleep
2000'timing ErrorCode0 = Err.Number end if
'secondary logic - to be
used for normal installations outside of LANDesk If NOT
filesys.FileExists(STARTCOUNTER) THEN 'msgbox "Counter does not exist in
LANDesk path" Err.Number = objShell.Run ("STARTCOUNTER.hta",9,True)
WScript.Sleep 2000'timing ErrorCode0 = Err.Number 'msgbox "step0 " &
ErrorCode0 'WScript.Quit(0) end if
'LAUNCH CORRECT SPLASH
SCREEN - separate logic provides granular control LANDeskLogo =
"C:\Progra~2\LANDesk\LDClient\sdmcache\APPS\"&AppPath&"\LANDesk.hta" 'primary
logic - to be used for LANDesk installations If
filesys.FileExists(LANDeskLogo) THEN 'msgbox "LANDesk Logo does exist in
LANDesk path" Err.Number = objShell.Run (LANDeskLogo,9,False)
WScript.Sleep 2000 ErrorCode0 = Err.Number end if
'secondary logic
- to be used for normal installations outside of LANDesk If NOT
filesys.FileExists(LANDeskLogo) THEN 'msgbox "LANDesk Logo does not exist in
LANDesk path" Err.Number = objShell.Run ("Kaplan.HTA",9,False)
WScript.Sleep 2000 ErrorCode0 = Err.Number 'msgbox "step0 " & ErrorCode0
'WScript.Quit(0) end if
'SET WORKING DIRECTORY AND LAUNCH MESSAGE
COMMAND FILE 'WINDOWS XP NORMAL PATH SDMCachePath =
"C:\Progra~2\LANDesk\LDClient\sdmcache\APPS\" & AppPath If
filesys.FolderExists(SDMCachePath) then on error resume next
objShell.CurrentDirectory = SDMCachePath End if
'ENABLED'TEMPORARILY
TURNS OFF AUTOMATIC UPDATES on error resume next Set objShell =
CreateObject("WScript.Shell") objShell.Run "%comspec% /c
%windir%\system32\net.exe stop wuauserv",0,True WScript.Sleep 2000
'ENABLED'PRE-INSTALLATION MAKE DIRECTORY objShell.Run "%comspec% /c md " &
chr(34) & "C:\Progra~2\LivePerson" & chr(34),0,True
'ENABLED'PRE-INSTALLATION SET FOLDER PERMISSIONS objShell.Run
"%windir%\system32\cacls.exe" & " " & chr(34) & "C:\Progra~2\LivePerson" &
chr(34) & " " & "/e /g everyone:f",0,True
'ENABLED'INSTALLS APPLICATION
WITH SILENT SWITCHES on error resume next
'primary logic - used for
LANDesk installation - separate logic provides granular control SetupPath =
"C:\Progra~2\LANDesk\LDClient\sdmcache\APPS\"&AppPath&"\lpsetup.exe" If
filesys.FileExists(SetupPath) THEN on error resume next Set objShell =
CreateObject("WScript.Shell") 'msgbox "Setup.msi does exist in LANDesk path"
WScript.Sleep 2000 Install = "%comspec% /c " & SetupPath & " /S"
Err.Number = objShell.Run (Install,0,False) WScript.Sleep 4000'wait for
installation ErrorCode4 = Err.Number 'msgbox "step4 " & ErrorCode4 end
if
'secondary logic - used for normal installation outside of LANDesk
If NOT filesys.FileExists(SetupPath) THEN on error resume next Set
objShell = CreateObject("WScript.Shell") 'msgbox "Setup.msi does not exist in
landesk path" WScript.Sleep 2000 'msgbox "exiting" 'WScript.Quit(0)
'performs silent installation except for a post setup splash screen Install =
"%comspec% /c lpsetup.exe /S" WScript.Sleep 4000'wait for installation
Err.Number = objShell.Run (Install,0,False) ErrorCode4 = Err.Number end if
'TASKKILL THE HC.EXE POST SETUP SPLASH SCREEN TO MAKE THE INSTALLATION
COMPLETELY SILENT objShell.Run "%comspec% /c %windir%\system32\taskkill.exe
/f /im hc.exe",0,True WScript.Sleep 1000 objShell.Run "%comspec% /c
%windir%\system32\taskkill.exe /f /im hc.exe",0,True WScript.Sleep 1000
objShell.Run "%comspec% /c %windir%\system32\taskkill.exe /f /im hc.exe",0,True
WScript.Sleep 1000 objShell.Run "%comspec% /c %windir%\system32\taskkill.exe
/f /im hc.exe",0,True WScript.Sleep 1000 objShell.Run "%comspec% /c
%windir%\system32\taskkill.exe /f /im hc.exe",0,True WScript.Sleep 1000
objShell.Run "%comspec% /c %windir%\system32\taskkill.exe /f /im hc.exe",0,True
WScript.Sleep 1000 objShell.Run "%comspec% /c %windir%\system32\taskkill.exe
/f /im hc.exe",0,True WScript.Sleep 1000 objShell.Run "%comspec% /c
%windir%\system32\taskkill.exe /f /im hc.exe",0,True WScript.Sleep 1000
objShell.Run "%comspec% /c %windir%\system32\taskkill.exe /f /im hc.exe",0,True
WScript.Sleep 1000 objShell.Run "%comspec% /c %windir%\system32\taskkill.exe
/f /im hc.exe",0,True WScript.Sleep 1000 objShell.Run "%comspec% /c
%windir%\system32\taskkill.exe /f /im hc.exe",0,True WScript.Sleep 1000
objShell.Run "%comspec% /c %windir%\system32\taskkill.exe /f /im hc.exe",0,True
'ENABLED'POST-INSTALLATION ADD DESKTOP ICON TO ALL USERS on error resume
next DELICON = "%comspec% /c del /q " & chr(34) &
"%userprofile%\Desktop\LivePerson.lnk"& chr(34) Err.Number = objShell.Run
(DELICON,0,True) WScript.Sleep 1000
ADDICON = "%comspec% /c copy /y /v
" & chr(34)&"%ALLUSERSPROFILE%\Start
Menu\Programs\LivePerson\LivePerson.lnk"&chr(34) & " " &
chr(34)&"%ALLUSERSPROFILE%\Desktop"&chr(34) Err.Number = objShell.Run
(ADDICON,0,False) WScript.Sleep 1000 '''ErrorCode7 = Err.Number 'msgbox
"step7 " & ErrorCode7 'WScript.Quit(0)
'ENABLED'TURNS ON
AUTOMATIC UPDATES on error resume next Set objShell =
CreateObject("Wscript.Shell") objShell.Run "%comspec% /c
%windir%\SYSTEM32\net.exe start wuauserv",0,False'STARTS THE WINDOWS UPDATE
SERVICE WScript.Sleep 2000 'msgbox "step9 " & ErrorCode9
'ENABLED'POST-INSTALLATION TASKKILLS objShell.Run "%comspec% /c
%windir%\system32\taskkill.exe /f /im mshta.exe",0,True'KILLS SPLASH SCREEN and
Logo Screen '''objShell.Run "%comspec% /c %windir%\system32\taskkill.exe /f
/im cmd.exe",0,True'KILLS ANY CMD.EXE
'ENABLED'HANDLES FINAL ERRORCODE
on error resume next if ErrorCode4 = 3010 then ErrorCode4 = 0'REBOOT if
ErrorCode4 = 1602 then ErrorCode4 = 0'REPAIR if ErrorCode4 = "" then
ErrorCode4 = 0'EMPTY
'TESTING DIAGNOSTIC 'msgbox "End Time: " &
TIME
'QUIT WITH ERROR CODE WScript.Quit(ErrorCode4) WScript.Quit(0)
End Sub
|
Δ
Tuesday, December 7th, 2010
Δ
WISE Installer
How to add switches to WISE.exe and UNWISE.exe, useful for
building your own packages.
Wise Setup.exe Switches
/T test mode /X pathname extracts files into pathname /Z pathname
extracts files into pathname and reboots /S silent install /M prompts
for windows, system, temp dirs /M=filename specifies a value file similar to
/d above, but for standard variables /M1 same as /m plus it prompts before
any file that is self-registered /M2 reserved for internal use by Wise
during debugger sessions
Uninstall (Unwise.exe switches)
/Z remove empty directories, including one with unwise itself in it. /A
automatic mode, no user choices other than cancel. /S silent mode, automatic
mode with no user choices /R rollback mode, selects option to rollback on
uninstall /U like automatic mode, but gives all choices other than
custom/automatic title window title can be at the end of the command line.
Δ
Distribute a Video File
How to distribute a video file to your enterprise
VBScript
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
':: E L I T E S O L U T I O N S ':: SCRIPT LANGUAGE: VBScript
':: SCRIPT NAME: VideoPackage_v1.vbs ':: PURPOSE: To be used to install video
from your deployment software ':: CREATION DATE: 12/06/2010 ':: LAST
MODIFIED: ':: DIRECTIONS: Send to client workstation ':: AUTHOR: Eddie
Jackson ':: EMAIL: MrNetTek2000@yahoo.com
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'VARIABLES on error resume next
Dim filesys, strComputer,
OSDetect, objWMIService, colInstances, sUser, strUser, objShell, Install,
Update, DELICON, Windows7_OS, XP_OS Dim SDMCache, AppPath, wshShell,
SetupFilesPath, SetupPath, Update1, Update2, Update3, Update4
AppPath =
"Misc\VideoPackage"
Set filesys =
CreateObject("Scripting.FileSystemObject") Set objShell =
CreateObject("Wscript.Shell") Set wshShell =
WScript.CreateObject("WScript.Shell")
'PRE-SETUP COMMANDS on error
resume next Set objShell = CreateObject("Wscript.Shell") objShell.Run
"%comspec% /c %windir%\system32\taskkill.exe /f /im cmd.exe",0,True
objShell.Run "%comspec% /c %windir%\system32\taskkill.exe /f /im
SetupFiles.exe",0,True objShell.Run "%comspec% /c
%windir%\system32\taskkill.exe /f /im mshta.exe",0,True
'SET WORKSTATION
NAME - PRIMARY METHOD strComputer = "."
'SET WORKSTATION NAME -
SECONDARY METHOD if strComputer = "" then on error resume next Set
wshNetwork = WScript.CreateObject( "WScript.Network" ) strComputer =
wshNetwork.ComputerName end if
'SET WORKSTATION NAME - TERTIARY METHOD
if strComputer = "" then on error resume next strComputer =
wshShell.ExpandEnvironmentStrings( "%COMPUTERNAME%" ) end if
'ENABLED'PRIMARY OS DETECTION Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20
Set objWMIService = GetObject(
"winmgmts://" & strComputer & "/root/CIMV2" ) Set colInstances =
objWMIService.ExecQuery( "SELECT * FROM Win32_OperatingSystem", "WQL",
wbemFlagReturnImmediately + wbemFlagForwardOnly )
For Each objInstance In
colInstances 'msgbox objInstance.Caption OSDetect = objInstance.Caption
Next
OSDetect = trim(OSDetect) 'msgbox OSDetect
if OSDetect =
"Microsoft Windows XP Professional" then XP() if OSDetect = "Microsoft
Windows XP" then XP() if OSDetect = "Microsoft Windows XP Home" then XP()
if OSDetect = "Microsoft Windows 7 Enterprise" then Seven() if OSDetect =
"Microsoft Windows 7 Enterprise Edition" then Seven() if OSDetect =
"Microsoft Windows 7 Ultimate" then Seven() if OSDetect = "Microsoft Windows
7 Ultimate Edition" then Seven() if OSDetect = "Microsoft Windows Server 2003
Standard" then XP() if OSDetect = "Microsoft Windows Server 2008 Standard"
then Seven() if OSDetect = "Microsoft Windows Server 2008 Standard Edition"
then Seven() if OSDetect = "Microsoft Windows Server 2008 Enterprise" then
Seven() if OSDetect = "Microsoft Windows Server 2008 Enterprise Edition" then
Seven() if OSDetect <> "Microsoft Windows Server 2008 Enterprise" then XP()
WScript.Quit(0)
'SETS UP SECONDARY OS DETECTION IF NEEDED Windows7_OS
= "C:\Users\Public" XP_OS = "C:\Documents and Settings"
'W I N D O W S
X P Sub XP on error resume next
'EXTRACT SPLASH SCREEN & COUNTER
FILES 'primary logic - to be used for LANDesk installations EXTRACTSPLASH
= "C:\Progra~1\LANDesk\LDClient\sdmcache\APPS\Microsoft\" & AppPath &
"\splash.exe" If filesys.FileExists(EXTRACTSPLASH) THEN objShell.Run
EXTRACTSPLASH,9,True end if
'secondary logic - to be used for normal
installations If NOT filesys.FileExists(EXTRACTSPLASH) THEN objShell.Run
"splash.exe",9,True end if
'LAUNCH CORRECT SPLASH SCREEN - separate
logic provides granular control STARTCOUNTER =
"C:\Progra~1\LANDesk\LDClient\sdmcache\APPS\" & AppPath & "\STARTCOUNTER.hta"
'primary logic - to be used for LANDesk installations If
filesys.FileExists(STARTCOUNTER) THEN 'msgbox "Counter does exist in LANDesk
path" Err.Number = objShell.Run (STARTCOUNTER,9,True) WScript.Sleep 2000
ErrorCode0 = Err.Number end if
'secondary logic - to be used for
normal installations If NOT filesys.FileExists(STARTCOUNTER) THEN 'msgbox
"Counter does not exist in LANDesk path" Err.Number = objShell.Run
("STARTCOUNTER.hta",9,True) WScript.Sleep 2000 ErrorCode0 = Err.Number
'msgbox "step0 " & ErrorCode0 'WScript.Quit(0) end if
'LAUNCH
CORRECT SPLASH SCREEN - separate logic provides granular control LANDeskLogo
= "C:\Progra~1\LANDesk\LDClient\sdmcache\APPS\" & AppPath & "\LANDesk.hta"
'primary logic - to be used for LANDesk installations If
filesys.FileExists(LANDeskLogo) THEN 'msgbox "LANDesk Logo does exist in
LANDesk path" Err.Number = objShell.Run (LANDeskLogo,9,False)
WScript.Sleep 2000 ErrorCode0 = Err.Number end if
'secondary logic
- to be used for normal installations If NOT filesys.FileExists(LANDeskLogo)
THEN 'msgbox "LANDesk Logo does not exist in LANDesk path" Err.Number =
objShell.Run ("Kaplan.HTA",9,False) WScript.Sleep 2000 ErrorCode0 =
Err.Number 'msgbox "step0 " & ErrorCode0 'WScript.Quit(0) end if
'SET WORKING DIRECTORY AND LAUNCH MESSAGE COMMAND FILE 'WINDOWS XP
NORMAL PATH SDMCachePath = "C:\Progra~1\LANDesk\LDClient\sdmcache\APPS\" &
AppPath If filesys.FolderExists(SDMCachePath) then on error resume next
objShell.CurrentDirectory = SDMCachePath End if
'DISABLE: RETURN
CURRENT USER '''sUser = ConsoleUser(".") '''strUser = Trim(sUser)
'MsgBox sUser
'ENABLED'TEMPORARILY TURNS OFF AUTOMATIC UPDATES on
error resume next Set objShell = CreateObject("WScript.Shell")
objShell.Run "%comspec% /c %windir%\system32\net.exe stop wuauserv",0,True
WScript.Sleep 2000
'ENABLED'MAKE DIRECTORY on error resume next
objShell.Run "%comspec% /c md " & chr(34) &
"C:\Progra~1\Paying_for_School_Video" & chr(34),0,True
'ENABLED'SET
FOLDER PERMISSIONS objShell.Run "%windir%\system32\cacls.exe" & " " & chr(34)
& "C:\Progra~1\Paying_for_School_Video" & chr(34) & " " & "/e /g
everyone:f",0,True
'ENABLED'COPY FILE on error resume next
CopyCommand = "%comspec% /c COPY /Y /V Paying_for_School_Video.flv" & " " &
chr(34)&"\\%computername%\C$\Progra~1\Paying_for_School_Video"&chr(34)
objShell.Run CopyCommand,0,True
'ENABLED'CREATE SHORTCUT
sAllUsersDesktopPath = objShell.SpecialFolders("AllUsersDesktop") Set
oShortCut = objShell.CreateShortcut(sAllUsersDesktopPath & "\-Paying for School-
Watch Video.lnk")
If
filesys.FileExists("C:\Progra~1\Paying_for_School_Video\Paying_for_School_Video.flv")
THEN oShortCut.TargetPath =
chr(34)&"C:\Progra~1\Paying_for_School_Video\Paying_for_School_Video.flv"&chr(34)
oShortCut.Arguments =
chr(34)&"C:\Progra~1\Paying_for_School_Video\Paying_for_School_Video.flv"&chr(34)
''' "C:\Windows\System32\shell32.dll,19" oShortCut.IconLocation =
"\\%computername%\C&\Progra~1\Paying_for_School_Video\Paying_for_School_Video.flv"
oShortCut.Save END IF
'ENABLED'TURNS ON AUTOMATIC UPDATES on error
resume next Set objShell = CreateObject("Wscript.Shell") objShell.Run
"%comspec% /c %windir%\SYSTEM32\net.exe start wuauserv",0,False'STARTS THE
WINDOWS UPDATE SERVICE WScript.Sleep 2000 'msgbox "step9 " & ErrorCode9
'ENABLED'POST-INSTALLATION TASKKILLS objShell.Run "%comspec% /c
%windir%\system32\taskkill.exe /f /im mshta.exe",0,True'KILLS SPLASH SCREEN and
Logo Screen '''objShell.Run "%comspec% /c %windir%\system32\taskkill.exe /f
/im cmd.exe",0,True'KILLS ANY CMD.EXE
'ENABLED'HANDLES FINAL ERRORCODE
on error resume next if ErrorCode4 = 3010 then ErrorCode4 = 0'REBOOT if
ErrorCode4 = 1602 then ErrorCode4 = 0'REPAIR if ErrorCode4 = "" then
ErrorCode4 = 0'EMPTY
'TESTING DIAGNOSTIC 'msgbox "End Time: " &
TIME
'QUIT WITH ERROR CODE 'WScript.Quit(ErrorCode4)
WScript.Quit(0) End Sub
'W I N D O W S 7 Sub SEVEN() on
error resume next
'EXTRACT SPLASH SCREEN & COUNTER FILES 'primary
logic - to be used for LANDesk installations EXTRACTSPLASH =
"C:\Progra~2\LANDesk\LDClient\sdmcache\APPS\" & AppPath & "\splash.exe" If
filesys.FileExists(EXTRACTSPLASH) THEN objShell.Run EXTRACTSPLASH,9,True
end if
'secondary logic - to be used for normal installations If NOT
filesys.FileExists(EXTRACTSPLASH) THEN objShell.Run "splash.exe",9,True
end if
'LAUNCH CORRECT SPLASH SCREEN - separate logic provides granular
control STARTCOUNTER = "C:\Progra~2\LANDesk\LDClient\sdmcache\APPS\" &
AppPath & "\STARTCOUNTER.hta" 'primary logic - to be used for LANDesk
installations If filesys.FileExists(STARTCOUNTER) THEN 'msgbox "Counter
does exist in LANDesk path" Err.Number = objShell.Run (STARTCOUNTER,9,True)
WScript.Sleep 2000 ErrorCode0 = Err.Number end if
'secondary logic
- to be used for normal installations If NOT filesys.FileExists(STARTCOUNTER)
THEN 'msgbox "Counter does not exist in LANDesk path" Err.Number =
objShell.Run ("STARTCOUNTER.hta",9,True) WScript.Sleep 2000 ErrorCode0 =
Err.Number 'msgbox "step0 " & ErrorCode0 'WScript.Quit(0) end if
'LAUNCH CORRECT SPLASH SCREEN - separate logic provides granular control
LANDeskLogo = "C:\Progra~2\LANDesk\LDClient\sdmcache\APPS\" & AppPath &
"\LANDesk.hta" 'primary logic - to be used for LANDesk installations If
filesys.FileExists(LANDeskLogo) THEN 'msgbox "LANDesk Logo does exist in
LANDesk path" Err.Number = objShell.Run (LANDeskLogo,9,False)
WScript.Sleep 2000 ErrorCode0 = Err.Number end if
'secondary logic
- to be used for normal installations If NOT filesys.FileExists(LANDeskLogo)
THEN 'msgbox "LANDesk Logo does not exist in LANDesk path" Err.Number =
objShell.Run ("Kaplan.HTA",9,False) WScript.Sleep 2000 ErrorCode0 =
Err.Number 'msgbox "step0 " & ErrorCode0 'WScript.Quit(0) end if
'SET WORKING DIRECTORY AND LAUNCH MESSAGE COMMAND FILE 'WINDOWS XP
NORMAL PATH SDMCachePath = "C:\Progra~2\LANDesk\LDClient\sdmcache\APPS\" &
AppPath If filesys.FolderExists(SDMCachePath) then on error resume next
objShell.CurrentDirectory = SDMCachePath End if
'DISABLE: RETURN
CURRENT USER '''sUser = ConsoleUser(".") '''strUser = Trim(sUser)
'MsgBox sUser
'ENABLED'TEMPORARILY TURNS OFF AUTOMATIC UPDATES on
error resume next Set objShell = CreateObject("WScript.Shell")
objShell.Run "%comspec% /c %windir%\system32\net.exe stop wuauserv",0,True
WScript.Sleep 2000
'ENABLED'INSTALLS APPLICATION WITH SILENT SWITCHES IF
AVAILABLE on error resume next
'ENABLED'MAKE DIRECTORY on error
resume next objShell.Run "%comspec% /c md " & chr(34) &
"C:\Progra~2\Paying_for_School_Video" & chr(34),0,True
'ENABLED'SET
FOLDER PERMISSIONS objShell.Run "%windir%\system32\cacls.exe" & " " & chr(34)
& "C:\Progra~2\Paying_for_School_Video" & chr(34) & " " & "/e /g
everyone:f",0,True
'ENABLED'COPY FILE on error resume next
CopyCommand = "%comspec% /c COPY /Y /V Paying_for_School_Video.flv" & " " &
chr(34)&"\\%computername%\C$\Progra~2\Paying_for_School_Video"&chr(34)
objShell.Run CopyCommand,0,True
'ENABLED'CREATE SHORTCUT
sAllUsersDesktopPath = objShell.SpecialFolders("AllUsersDesktop") Set
oShortCut = objShell.CreateShortcut(sAllUsersDesktopPath & "\-Paying for School-
Watch Video.lnk")
If
filesys.FileExists("C:\Progra~2\Paying_for_School_Video\Paying_for_School_Video.flv")
THEN oShortCut.TargetPath =
chr(34)&"C:\Progra~2\Paying_for_School_Video\Paying_for_School_Video.flv"&chr(34)
oShortCut.Arguments =
chr(34)&"C:\Progra~2\Paying_for_School_Video\Paying_for_School_Video.flv"&chr(34)
''' "C:\Windows\System32\shell32.dll,19" oShortCut.IconLocation =
"C:\Progra~2\Paying_for_School_Video\Paying_for_School_Video.flv"
oShortCut.Save END IF
'ENABLED'TURNS ON AUTOMATIC UPDATES on error
resume next Set objShell = CreateObject("Wscript.Shell") objShell.Run
"%comspec% /c %windir%\SYSTEM32\net.exe start wuauserv",0,False'STARTS THE
WINDOWS UPDATE SERVICE WScript.Sleep 2000 'msgbox "step9 " & ErrorCode9
'ENABLED'POST-INSTALLATION TASKKILLS objShell.Run "%comspec% /c
%windir%\system32\taskkill.exe /f /im mshta.exe",0,True'KILLS SPLASH SCREEN and
Logo Screen '''objShell.Run "%comspec% /c %windir%\system32\taskkill.exe /f
/im cmd.exe",0,True'KILLS ANY CMD.EXE 'ENABLED'HANDLES FINAL ERRORCODE on
error resume next if ErrorCode4 = 3010 then ErrorCode4 = 0'REBOOT if
ErrorCode4 = 1602 then ErrorCode4 = 0'REPAIR if ErrorCode4 = "" then
ErrorCode4 = 0'EMPTY
'TESTING DIAGNOSTIC 'msgbox "End Time: " &
TIME
'QUIT WITH ERROR CODE 'WScript.Quit(ErrorCode4)
WScript.Quit(0) End Sub
|
Δ
Monday, December 6th, 2010
Δ
Re-Write Text File From Bottom To Top
How to re-write a text file so it will read from top(most
current) to
bottom(oldest), useful for changing the order of a log file.
VBScript:
'ForAppending = 8 ForReading = 1, ForWriting = 2 Const ForReading = 1 Set
fso = CreateObject( "Scripting.FileSystemObject" ) Set history =
fso.OpenTextFile("c:\output.txt", 2) Set textFile = fso.OpenTextFile(
"c:\input.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
|
Δ
Saturday, December 4th, 2010
Δ
Return SID-Username-Load Reg-Apply Reg Keys
How to return SID, username, load user registry, and then apply reg keys
to user profile; this will load each user profile.
VBScript:
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
':: E L I T E S O L U T I O N S ':: SCRIPT LANGUAGE: VBScript '::
SCRIPT NAME: LoadReg_GetUsername_GetSID_ApplyRegKey.vbs ':: PURPOSE: To be
used to apply registry keys to each profile ':: CREATION DATE: 12/04/2010
':: LAST MODIFIED: ':: DIRECTIONS: to be added to full script ':: AUTHOR:
Eddie Jackson - Software Packaging Engineer ':: EMAIL: MrNetTek2000@yahoo.com
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
On Error Resume Next
DIM objWMIService, objAccount, sUser, objSubkey,
strKeyPath, strSubPath, strComputer, strValue, REGEDIT Set objShell =
CreateObject("WScript.Shell") Const HKEY_LOCAL_MACHINE = &H80000002
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" &
strComputer & "\root\cimv2")
Set
objRegistry=GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
strKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList"
objRegistry.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubkeys For Each
objSubkey In arrSubkeys strValueName = "ProfileImagePath" strSubPath =
strKeyPath & "\" & objSubkey objRegistry.GetExpandedStringValue
HKEY_LOCAL_MACHINE,strSubPath,strValueName,strValue Const POPUP_TITLE = "User
To SID Conversion" Set objWMIService = GetObject("winmgmts:\\" & strComputer
& "\root\cimv2") Set objAccount = objWMIService.Get("Win32_SID.SID='" &
objSubkey & "'") strUser = objAccount.AccountName 'strDomain =
objAccount.ReferencedDomainName'returns referenced domain
'DISPLAY
PROFILE NAME & SID objSubkey = trim(objSubkey)'trims whitespace strUser =
trim(strUser)'trims whitespace msgbox "objSubkey: " & objSubkey'returns SID
msgbox strUser'returns username
'LOGIC TO DETERMINE IF REGISTRY ACCOUNT
IS TO BE LOADED if strUser = "SYSTEM" then strUser="" if strUser = "LOCAL
SERVICE" then strUser="" if strUser = "NETWORK SERVICE" then strUser="" if
strUser = "ADMINISTRATOR" then strUser=""
if strUser <> "" then
'LOADS HIVE on error resume next REGEDIT = "%comspec% /c
%windir%\system32\REG.exe LOAD HKEY_USERS\"&objSubkey&"
c:\Docume~1\"&strUser&"\ntuser.dat" 'COMMAND reg.exe load
HKU\S-1-5-21-729355473-1286879909-xxxxxxxxx-xxxxx c:\Docume~1\prosys\ntuser.dat
Err.Number = objShell.Run (REGEDIT,0,True) ErrorCode8 = Err.Number
WScript.Sleep 2000'timing
'ENABLED'POST-INSTALLATION REGEDIT - DISABLE
REGISTRATION on error resume next REGEDIT = "%comspec% /c
%windir%\system32\REG.exe ADD "&
chr(34)&"HKEY_USERS\"&objSubkey&"\Software\TechSmith\SnagIt\10"&chr(34)&" /v
"&chr(34)&"RegistrationDialogHasShown"&CHR(34)&" /d 0 /t REG_DWORD /f"
'command: REG.exe ADD "HKCU\Software\TechSmith\SnagIt\10" /v
"RegistrationDialogHasShown" /d 1 /t REG_DWORD /f Err.Number = objShell.Run
(REGEDIT,0,True) ErrorCode8 = Err.Number WScript.Sleep 2000'timing
'msgbox "step8 " & ErrorCode8 'WScript.Quit(0)
'UNLOADS HIVE'DISABLED
'REGEDIT = "%comspec% /c %windir%\system32\REG.exe UNLOAD HKEY_USERS\"&objSubkey
end if Next
WScript.Quit(0)
|
Δ
Friday, December 3rd, 2010
Δ
Return Current Dir and Program Files
How to dynamically return current directory and assign it
a variable
VBScript:
Set
fso=CreateObject("Scripting.FileSystemObject") Set WshShell =
WScript.CreateObject("WScript.Shell")
strCurrentDir =
fso.GetParentFolderName(WScript.ScriptFullName)
If
Right(strCurrentDir,1) <> "\" Then strCurrentDir = strCurrentDir & "\"
strProgramFiles = wshshell.expandenvironmentstrings("%programfiles%")
msgbox strCurrentDir msgbox strProgramFiles
'HTA only
'strCurrentDirectory = objShell.CurrentDirectory 'msgbox strCurrentDirectory
|
Δ
PING Connection If-Exist
How to verify a network connection has been established, useful if an online
connection is required.
Shell
:VERIFYCOM @rem THIS WILL VERIFY IF THEY ARE ALREADY ONLINE AND GOTO IMPORT
ELSE GOTO STARTCOM ping "X.X.X.X" -n 1 | find "Reply" > nul if errorlevel
1 goto STARTCOM else cls Echo You are NOT connected ping -n 5
127.0.0.1>nul goto VERIFYCOM
:STARTCOM cls Echo You are
connected! ping -n 5 127.0.0.1>nul
|
Δ
Thursday, December 2nd, 2010
Δ
Check Running Process
How to check if process is running and then do something,
useful if you need to wait for a process to be completed.
VBScript:
Function CHKPROC Set colProcessList = objWMIService.ExecQuery ("Select * from
Win32_Process Where Name = 'notepad.exe'") For Each objProcess in
colProcessList If objProcess.Name="notepad.exe" Then CHKPROC = 1 end
if Next End Function
|
Δ
Wednesday, December 1st, 2010
Δ
Return SID and Return Username from Explorer.exe
How to return SID and username
VBScript:
strComputer = "." sUser = ConsoleUser(".") strUser = Trim(sUser)
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set objAccount =
objWMIService.Get("Win32_UserAccount.Name='"&sUser&"',Domain='charlie'")
msgbox struser msgbox objAccount.SID
'THIS FUNCTION RETURNS OWNER OF EXPLORER.EXE
PROCESS Function ConsoleUser(sHost) on error resume next ' Returns
name of user logged on to console ' If no users are logged on, returns ""
Dim oWMI, colProc, oProcess, sUser, sDomain Set oWmi =
GetObject("winmgmts:" _ & "{impersonationLevel=impersonate,(debug)}!\\" _
& sHost & "\root\cimv2" )
Set colProc = oWmi.ExecQuery("Select Name
from Win32_Process" _ & " Where Name='explorer.exe' and SessionID=0" )
ConsoleUser = "" For Each oProcess In colProc lRet =
oProcess.GetOwner(sUser, sDomain) If lRet = 0 Then sUser = Trim(sUser)
ConsoleUser = sUser End If Next End Function
|
|