Archive - September 2010
"Genius is nothing but a great aptitude for patience." - George-Louis De Buffon
Δ
Thursday, September 30th 2010
![bar1](http://eddiejackson.net/web_images/lightgraybar.bmp)
Δ
DPInst.exe-Driver
Installs and Subdirectories
How to execute DPInst.exe on all subdirectories
(useful if you need to install multiple drivers during the imaging/build
process)
I use this in WDS to install all my 64 bit drivers. So, how this works
is as simple as pointing WDS-Synchronous command to load this .cmd file on first
logon.
Shell
![bar1](http://eddiejackson.net/web_images/lightgraybar.bmp)
@echo off net use t: \\server1\remoteinstall\drivers
/user:blackops.net\deploy welcome99$ if not exist t:\dpinst64.exe net use t:
\\server1\remoteinstall\drivers /user:blackops.net\deploy welcome99$ t:
for /f "delims=" %%a in ('dir /b /s *.') do ( cd %%a Echo Looking for
INF in %%a... dir *.inf | find "inf" && ( Echo Found INF in %%a... copy
/V /Y t:\dpinst64.exe %%a if exist %%a\DPInst64.exe start /w DPInst64.exe /q
/se /lm /sw /sh /sa /el /f ) ) c:\windows\system32\taskkill.exe /f /im
cmd.exe exit /b 0
![bar1](http://eddiejackson.net/web_images/lightgraybar.bmp)
|
![bar1](http://eddiejackson.net/web_images/lightgraybar.bmp)
Δ
Monday, September 27th 2010
![bar1](http://eddiejackson.net/web_images/lightgraybar.bmp)
Δ
Microsoft Project 2007 Professional Deployment
How to deploy Project 2007 to your enterprise
VBScript: Install
![bar1](http://eddiejackson.net/web_images/lightgraybar.bmp)
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
':: E L I T E S O L U T I O N S ':: SCRIPT LANGUAGE: VBScript
':: SCRIPT NAME: Project2007ProInstall.vbs ':: LOCATION: ':: PURPOSE: To
be used to Install Project 2007 Professional ':: DIRECTIONS: Send to client
workstation ':: CREATION DATE: 09/27/2010 ':: LAST MODIFIED: '::
AUTHOR: Eddie Jackson ':: EMAIL: MrNetTek2000@yahoo.com
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'DEFINE GLOBAL VARIABLES 'ON ERROR RESUME NEXT Dim filesys,
strComputer, OSDetect, objWMIService, colInstances, sUser, strUser, objShell,
Install, Update, DELICON, Windows7_OS, XP_OS Dim CopyCommand Set filesys =
CreateObject("Scripting.FileSystemObject") Set objShell =
CreateObject("Wscript.Shell")
'SETS WORKING DIRECTORY on error resume
next objShell.CurrentDirectory =
"c:\Progra~1\LANDesk\LDClient\sdmcache\APPS\Microsoft\Project2007Pro"
'CLEAR PROCESSES 'KILLS CURRENTLY RUNNING MSIEXEC.EXE objShell.Run
"cmd /c C:\WINDOWS\SYSTEM32\TASKKILL.EXE /F /IM msiexec.exe",0,True
'KILLS CURRENTLY RUNNING SETUP.EXE objShell.Run "cmd /c
C:\WINDOWS\SYSTEM32\TASKKILL.EXE /F /IM setup.exe",0,True
'SET
WORKSTATION NAME - PRIMARY strComputer = "."
'SET WORKSTATION NAME -
SECONDARY if strComputer = "" then 'On error resume next Set WshNetwork
= WScript.CreateObject("WScript.Network") strComputer =
WshNetwork.ComputerName end if
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 7 Enterprise" then
Seven()
'SETS UP SECONDARY OS DETECTION IF NEEDED Set filesys =
CreateObject("Scripting.FileSystemObject") Windows7_OS = "C:\Users\Public"
XP_OS = "C:\Docume~1\Administrator"
'SECONDARY DETECTION LOGIC If
filesys.FolderExists(Windows7_OS) then Seven() If filesys.FolderExists(XP_OS)
then XP() if OSDetect <> "Microsoft Windows 7 Enterprise" then XP()
'W I N D O W S X P O P E R A T I N G S Y S T E M Sub XP 'ON ERROR
RESUME NEXT
'DEFINE LOCAL VARIABLES
'ENABLED'TEMPORARILY TURNS OFF
AUTOMATIC UPDATES 'ON ERROR RESUME NEXT WScript.Sleep 2000 Set objShell
= CreateObject("WScript.Shell") objShell.Run "cmd /c net stop
wuauserv",0,True
'ENABLED'PRE-INSTALLATION EXTRACTS FILES /REQUIRED SETUP
FILES TO SDMCACHE 'ON ERROR RESUME NEXT WScript.Sleep 2000 If NOT
filesys.FileExists("Setup.exe") THEN Err.Number = objShell.Run
("SetupFiles.exe",9,True)
WScript.Sleep 2000 ErrorCode0 = Err.Number
'msgbox "step0 " & ErrorCode0 'WScript.Quit(0) end if
'ENABLED'PRE-INSTALLATION COPY FILE - this file is used for the uninstall
process CopyCommand = "cmd /c COPY /Y " & chr(34) &
"UnInstallProjectConfig.XML"&chr(34) &" "& chr(34)&"%ProgramFiles%\Microsoft
Office\Office12"&chr(34) 'msgbox CopyCommand objShell.Run
CopyCommand,0,True
'ENABLED'Remove APPLICATION 'ON ERROR RESUME NEXT
WScript.Sleep 2000 Remove2 = chr(34)&"setup.exe"&chr(34)&" /uninstall PRJPRO
/config " & chr(34)&"%ProgramFiles%\Microsoft
Office\Office12\UnInstallProjectConfig.XML"&chr(34) Err.Number = objShell.Run
(Remove2,0,True) ErrorCode3 = Err.Number 'msgbox "step3 " & ErrorCode3
'WScript.Quit(0)
'ENABLED'INSTALLS APPLICATION 'ON ERROR RESUME
NEXT WScript.Sleep 2000 Install = chr(34)&"setup.exe"&chr(34) 'msgbox
Install Err.Number = objShell.Run (Install,0,True) ErrorCode4 = Err.Number
'msgbox "step4 " & ErrorCode4 'WScript.Quit(0)
'ENABLED'TURNS ON
AUTOMATIC UPDATES 'ON ERROR RESUME NEXT WScript.Sleep 2000 objShell.Run
"cmd /c net start wuauserv",0,False 'msgbox "step9 " & ErrorCode9
'KILLS CURRENTLY RUNNING MSIEXEC.EXE WScript.Sleep 2000 objShell.Run "cmd
/c C:\WINDOWS\SYSTEM32\TASKKILL.EXE /F /IM msiexec.exe",0,True
'ENABLED'HANDLES FINAL ERRORCODE 'ON ERROR RESUME NEXT if ErrorCode4 =
3010 then ErrorCode4 = 0 if ErrorCode4 = 1602 then ErrorCode4 = 0 if
ErrorCode4 = "" then ErrorCode4 = 0 WScript.Quit(ErrorCode4) End Sub
'W I N D O W S 7 O P E R A T I N G S Y S T E M Sub SEVEN()
'ON ERROR RESUME NEXT
'DEFINE LOCAL VARIABLES
'ENABLED'TEMPORARILY
TURNS OFF AUTOMATIC UPDATES 'ON ERROR RESUME NEXT WScript.Sleep 2000
Set objShell = CreateObject("WScript.Shell") objShell.Run "cmd /c net stop
wuauserv",0,True
'ENABLED'PRE-INSTALLATION EXTRACTS FILES /REQUIRED SETUP
FILES TO SDMCACHE 'ON ERROR RESUME NEXT WScript.Sleep 2000 If NOT
filesys.FileExists("Setup.exe") THEN Err.Number = objShell.Run
("SetupFiles.exe",9,True)
WScript.Sleep 2000 ErrorCode0 = Err.Number
'msgbox "step0 " & ErrorCode0 'WScript.Quit(0) end if
'ENABLED'PRE-INSTALLATION COPY FILE - this file is used for the uninstall
process CopyCommand = "cmd /c COPY /Y " & chr(34) &
"UnInstallProjectConfig.XML"&chr(34) &" "& chr(34)&"%ProgramFiles%\Microsoft
Office\Office12"&chr(34) 'msgbox CopyCommand objShell.Run
CopyCommand,0,True
'ENABLED'Remove APPLICATION 'ON ERROR RESUME
NEXT WScript.Sleep 2000 Remove2 = chr(34)&"setup.exe"&chr(34)&" /uninstall
PRJPRO /config " & chr(34)&"%ProgramFiles%\Microsoft
Office\Office12\UnInstallProjectConfig.XML"&chr(34) Err.Number = objShell.Run
(Remove2,0,True) ErrorCode3 = Err.Number 'msgbox "step3 " & ErrorCode3
'WScript.Quit(0)
'ENABLED'INSTALLS APPLICATION 'ON ERROR RESUME
NEXT WScript.Sleep 2000 Install = chr(34)&"setup.exe"&chr(34) 'msgbox
Install Err.Number = objShell.Run (Install,0,True) ErrorCode4 = Err.Number
'msgbox "step4 " & ErrorCode4 'WScript.Quit(0)
'ENABLED'TURNS ON
AUTOMATIC UPDATES 'ON ERROR RESUME NEXT WScript.Sleep 2000 objShell.Run
"cmd /c net start wuauserv",0,False 'msgbox "step9 " & ErrorCode9
'KILLS CURRENTLY RUNNING MSIEXEC.EXE WScript.Sleep 2000 objShell.Run "cmd
/c C:\WINDOWS\SYSTEM32\TASKKILL.EXE /F /IM msiexec.exe",0,True
'ENABLED'HANDLES FINAL ERRORCODE 'ON ERROR RESUME NEXT if ErrorCode4 =
3010 then ErrorCode4 = 0 if ErrorCode4 = 1602 then ErrorCode4 = 0 if
ErrorCode4 = "" then ErrorCode4 = 0 WScript.Quit(ErrorCode4) End Sub
'THIS FUNCTION RETURNS LOGGED IN STATUS WITH A TRUE-FOR LOGGED IN OR
FALSE-NOT LOGGED IN Function UserLoggedInStatus() 'ON ERROR RESUME NEXT
Dim LoggedInStatus, objWMIService, colItems
'Example 'strComputer =
"." 'If UserLoggedInStatus = TRUE then msgbox "user IS logged in" 'If
UserLoggedInStatus = FALSE then msgbox "user NOT logged in"
Set
objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set
colItems = objWMIService.ExecQuery("Select * from Win32_ComputerSystem",,48)
For Each objItem in colItems 'ON ERROR RESUME NEXT 'Wscript.Echo
objItem.UserName LoggedInStatus = trim(objItem.UserName) & "" next
if LoggedInStatus = "" then 'msgbox "User NOT logged in"
UserLoggedInStatus = FALSE end if
if LoggedInStatus <> "" then
'msgbox "User IS logged in" UserLoggedInStatus = TRUE end if
Set
objItem = Nothing Set colItems = Nothing Set objWMIService = Nothing
End function
'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
'THIS FUNCTION RETURNS 32 or 64 bit for OS
Function OS_TYPE() 'ON ERROR RESUME NEXT Const HKLM = &H80000002
arrComputers = Array(".")
For Each strComputer In arrComputers 'ON
ERROR RESUME NEXT Set WshShell = WScript.CreateObject("WScript.Shell")
'CHECKING THE REGISTRY VALUE X =
WshShell.RegRead("HKLM\HARDWARE\DESCRIPTION\System\CentralProcessor\0\Identifier")
'TAKING 3 CHARECTERS FROM LEFT SIDE OF RESULT X1 = Left(X,3) 'CHECK
VERSION AGAINST X86 If X1 = "x86" Then 'WScript.Echo "32- Bit OS"
OS_TYPE = 32 Else 'WScript.Echo "64- Bit OS" OS_TYPE = 64 End if
Next end function
'THIS FUNCTION RETURNS GENERAL TIME OF DAY;
MORNING, AFTERNOON, EVENING Function TimeOfDay() 'ON ERROR RESUME NEXT
Dim h 'create variable that will store the hour
'EXAMPLE 'msgbox
TimeOfDay()
h=hour(now) 'pass in the date and time to the hour function
as a parameter If h<12 then 'msgbox "morning!" TimeOfDay = "morning"
ElseIf h<18 then 'msgbox "afternoon!" TimeOfDay = "afternoon" else
'msgbox "evening!" TimeOfDay = "evening" end if End function
![bar1](http://eddiejackson.net/web_images/lightgraybar.bmp)
|
![bar1](http://eddiejackson.net/web_images/lightgraybar.bmp)
Δ
Monday, September 20th 2010
![bar1](http://eddiejackson.net/web_images/lightgraybar.bmp)
Δ
Microsoft Visio 2007 Enterprise Deployment
How to deploy Visio 2007 Pro to your enterprise
VBScript: Install
![bar1](http://eddiejackson.net/web_images/lightgraybar.bmp)
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
':: E L I T E S O L U T I O N S ':: SCRIPT LANGUAGE: VBScript
':: SCRIPT NAME: Visio2007ProInstall.vbs ':: LOCATION: YourComputer '::
PURPOSE: To be used to Install Visio 2007 Professional ':: DIRECTIONS: Send
to client workstation ':: CREATION DATE: 09/22/2010 ':: LAST MODIFIED:
':: AUTHOR: Eddie Jackson ':: EMAIL: MrNetTek2000@yahoo.com
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'DEFINE GLOBAL VARIABLES ON ERROR RESUME NEXT Dim filesys,
strComputer, OSDetect, objWMIService, colInstances, sUser, strUser, objShell,
Install, Update, DELICON, Windows7_OS, XP_OS Dim CopyCommand Set filesys =
CreateObject("Scripting.FileSystemObject") Set objShell =
CreateObject("Wscript.Shell")
'POLICY DISABLED 'FilterFile =
"c:\Program Files\YourProgram\foo.exe" 'If filesys.FileExists(FilterFile)
THEN 'WScript.Quit(0) 'End if
'SETS WORKING DIRECTORY
objShell.CurrentDirectory =
"c:\Progra~1\LANDesk\LDClient\sdmcache\APPS\Microsoft\Visio2007Pro"
'CLEAR PROCESSES 'KILLS CURRENTLY RUNNING MSIEXEC.EXE objShell.Run "cmd /c
C:\WINDOWS\SYSTEM32\TASKKILL.EXE /F /IM msiexec.exe",0,True
'KILLS
CURRENTLY RUNNING SETUP.EXE objShell.Run "cmd /c
C:\WINDOWS\SYSTEM32\TASKKILL.EXE /F /IM setup.exe",0,True
'SET
WORKSTATION NAME strComputer = "."
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 7 Enterprise" then
Seven()
'SETS UP SECONDARY OS DETECTION IF NEEDED Set filesys =
CreateObject("Scripting.FileSystemObject") Windows7_OS = "C:\Users\Public"
XP_OS = "C:\Docume~1\Administrator"
'SECONDARY DETECTION LOGIC If
filesys.FolderExists(Windows7_OS) then Seven() If filesys.FolderExists(XP_OS)
then XP() if OSDetect <> "Microsoft Windows 7 Enterprise" then XP()
'W I N D O W S X P O P E R A T I N G S Y S T E M Sub XP ON ERROR
RESUME NEXT
'DEFINE LOCAL VARIABLES Dim VisioFile
'ENABLED'TEMPORARILY TURNS OFF AUTOMATIC UPDATES ON ERROR RESUME NEXT
WScript.Sleep 2000 Set objShell = CreateObject("WScript.Shell")
objShell.Run "cmd /c net stop wuauserv",0,True
'ENABLED'PRE-INSTALLATION EXTRACTS FILES /REQUIRED SETUP FILES TO SDMCACHE ON
ERROR RESUME NEXT WScript.Sleep 2000 If NOT
filesys.FileExists("Setup.exe") THEN Err.Number = objShell.Run
("SetupFiles.exe",9,True)
WScript.Sleep 2000 ErrorCode0 = Err.Number
'msgbox "step0 " & ErrorCode0 'WScript.Quit(0) end if
'ENABLED'PRE-INSTALLATION COPY FILE - this file is used for the uninstall
process CopyCommand = "cmd /c COPY /Y " & chr(34) &
"%ProgramFiles%\landesk\LDClient\sdmcache\APPS\Microsoft\Visio2007Pro\UnInstallVisioConfig.XML"&chr(34)
&" "& chr(34)&"%ProgramFiles%\Microsoft Office\Office12"&chr(34) 'msgbox
CopyCommand objShell.Run CopyCommand,0,True
'ENABLED'Remove
APPLICATION ON ERROR RESUME NEXT WScript.Sleep 2000 Remove2 =
chr(34)&"%ProgramFiles%\Common Files\Microsoft Shared\OFFICE12\Office Setup
Controller\setup.exe"&chr(34)&" /uninstall VISPRO /config " &
chr(34)&"%ProgramFiles%\Microsoft
Office\Office12\UnInstallVisioConfig.XML"&chr(34) Err.Number = objShell.Run
(Remove2,0,True) ErrorCode3 = Err.Number 'msgbox "step3 " & ErrorCode3
'WScript.Quit(0)
'ENABLED'INSTALLS APPLICATION ON ERROR RESUME
NEXT WScript.Sleep 2000 Install =
chr(34)&"%ProgramFiles%\landesk\LDClient\sdmcache\APPS\Microsoft\Visio2007Pro\setup.exe"&chr(34)
'msgbox Install Err.Number = objShell.Run (Install,0,True) ErrorCode4 =
Err.Number 'msgbox "step4 " & ErrorCode4 'WScript.Quit(0)
'ENABLED'TURNS ON AUTOMATIC UPDATES ON ERROR RESUME NEXT WScript.Sleep
2000 objShell.Run "cmd /c net start wuauserv",0,False 'msgbox "step9 " &
ErrorCode9
'KILLS CURRENTLY RUNNING MSIEXEC.EXE WScript.Sleep 2000
objShell.Run "cmd /c C:\WINDOWS\SYSTEM32\TASKKILL.EXE /F /IM msiexec.exe",0,True
'ENABLED'HANDLES FINAL ERRORCODE ON ERROR RESUME NEXT if ErrorCode4 =
3010 then ErrorCode4 = 0 if ErrorCode4 = 1602 then ErrorCode4 = 0 if
ErrorCode4 = "" then ErrorCode4 = 0 WScript.Quit(ErrorCode4) End Sub
'W I N D O W S 7 O P E R A T I N G S Y S T E M Sub SEVEN() ON
ERROR RESUME NEXT
'DEFINE LOCAL VARIABLES Dim VisioFile
'ENABLED'TEMPORARILY TURNS OFF AUTOMATIC UPDATES ON ERROR RESUME NEXT
WScript.Sleep 2000 Set objShell = CreateObject("WScript.Shell")
objShell.Run "cmd /c net stop wuauserv",0,True
'ENABLED'PRE-INSTALLATION EXTRACTS FILES REQUIRED SETUP FILES TO SDMCACHE ON
ERROR RESUME NEXT WScript.Sleep 2000 If NOT
filesys.FileExists("Setup.exe") THEN Err.Number = objShell.Run
("SetupFiles.exe",9,True)
WScript.Sleep 2000 ErrorCode0 = Err.Number
'msgbox "step0 " & ErrorCode0 'WScript.Quit(0) end if
'ENABLED'PRE-INSTALLATION COPY FILE - this file is used for the uninstall
process CopyCommand = "cmd /c COPY /Y " & chr(34) & "c:\Program Files
(x86)\landesk\LDClient\sdmcache\APPS\Microsoft\Visio2007Pro\UnInstallVisioConfig.XML"&chr(34)
&" "& chr(34)&"%ProgramFiles%\Microsoft Office\Office12"&chr(34) 'msgbox
CopyCommand objShell.Run CopyCommand,0,True
'ENABLED'Remove
APPLICATION ON ERROR RESUME NEXT WScript.Sleep 2000 Remove2 =
chr(34)&"c:\Program Files (x86)\Common Files\Microsoft Shared\OFFICE12\Office
Setup Controller\setup.exe"&chr(34)&" /uninstall VISPRO /config " &
chr(34)&"%ProgramFiles%\Microsoft
Office\Office12\UnInstallVisioConfig.XML"&chr(34) Err.Number = objShell.Run
(Remove2,0,True) ErrorCode3 = Err.Number 'msgbox "step3 " & ErrorCode3
'WScript.Quit(0)
'ENABLED'INSTALLS APPLICATION ON ERROR RESUME
NEXT WScript.Sleep 2000 Install = chr(34)&"c:\Program Files
(x86)\landesk\LDClient\sdmcache\APPS\Microsoft\Visio2007Pro\setup.exe"&chr(34)
'msgbox Install Err.Number = objShell.Run (Install,0,True) WScript.Sleep
2000 ErrorCode4 = Err.Number 'msgbox "step4 " & ErrorCode4
'WScript.Quit(0)
'ENABLED'TURNS ON AUTOMATIC UPDATES ON ERROR
RESUME NEXT WScript.Sleep 2000 objShell.Run "cmd /c net start
wuauserv",0,False 'msgbox "step9 " & ErrorCode9
'KILLS CURRENTLY
RUNNING MSIEXEC.EXE WScript.Sleep 2000 objShell.Run "cmd /c
C:\WINDOWS\SYSTEM32\TASKKILL.EXE /F /IM msiexec.exe",0,True
'ENABLED'HANDLES FINAL ERRORCODE ON ERROR RESUME NEXT if ErrorCode4 = 3010
then ErrorCode4 = 0 if ErrorCode4 = 1602 then ErrorCode4 = 0 if ErrorCode4
= "" then ErrorCode4 = 0 WScript.Quit(ErrorCode4) End Sub
![bar1](http://eddiejackson.net/web_images/lightgraybar.bmp)
|
![bar1](http://eddiejackson.net/web_images/lightgraybar.bmp)
Δ
Monday, September 15th 2010
![bar1](http://eddiejackson.net/web_images/lightgraybar.bmp)
Δ
WSUS Reg Key - Automatic Updates For Clients
How to apply custom WSUS settings by registry key
The best way to push down Microsoft WSUS settings to client computers is by
using Microsoft Active Directory Services if your systems are in a domain or
by using the Local Group Policy Object if your workstations are located on a
workgroup. There are some other ways to push down these settings if you need
to do it in some other fashion. The easiest way would be to create a Registry
File called WSUS_Update.reg
to import into your clients, adjusting the
settings to correct
values for your network. Place this file in the root of your systems drive.
The following is an example of a registry file to create these settings:
Reg Key
![bar1](http://eddiejackson.net/web_images/lightgraybar.bmp)
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate]
"WUServer"=http://YOUR-WSUS-SERVER
"WUStatusServer"=http://YOUR-WSUS-SERVER
"TargetGroupEnabled"=dword:00000001 "TargetGroup"=Change Group
"ElevateNonAdmins"=dword:00000000
[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU]
"NoAutoUpdate"=dword:00000000 "AUOptions"=dword:00000004
"AutoInstallMinorUpdate"=dword:00000001
"DetectionFrequencyEnabled"=dword:00000001
"DetectionFrequency"=dword:00000001
"NoAutoRebootWithLoggedOnUsers"=dword:00000000
"RebootRelaunchTimeout"=dword:000000x5
"RebootRelaunchTimeoutEnabled"=dword:00000001
"RebootWarningTimeout"=dword:000000x5
"RebootWarningTimeoutEnabled"=dword:00000001
"RescheduleWaitTimeEnabled"=dword:00000001
"RescheduleWaitTime"=dword:0000001e "ScheduledInstallDay"=dword:00000000
"ScheduledInstallTime"=dword:0x14 "UseWUServer"=dword:00000001
"LastWaitTimeout"=-
![bar1](http://eddiejackson.net/web_images/lightgraybar.bmp)
|
In this example, you would need to change the TargetGroup to
match your environment settings. Also, the WUServer and WUStatusServer would
need to be changed to your Microsoft WSUS server. I put these setting in bold
type face above to help you find them. You could easily go to each
workstation and import this file into each workstation's registry. I would
recommend using a script file instead and use it to import the registry file
and restart the Windows Update service on the client workstation. You would
need to create the script with a CMD or BAT extension to run properly.
An example script is below, this script assumes the registry file
WSUS_Update.REG is in the root of the systems drive:
![bar1](http://eddiejackson.net/web_images/lightgraybar.bmp)
Net Stop wuauserv Echo Importing
WSUS_Update.REG %windir%\Regedit.exe /s C:\WSUS_Update.REG Echo WSUS.reg
imported succesfully Net Start wuauserv
![bar1](http://eddiejackson.net/web_images/lightgraybar.bmp)
|
As you can see, there are other ways to change the WSUS settings on a
client without using Active Directory Group Policy Objects or Local Group
Policy Objects
Δ
Symantec Service Restart-Reset HardwareID
How to stop and start the smc service and reset the
HardwareID
VBScript
![bar1](http://eddiejackson.net/web_images/lightgraybar.bmp)
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
':: SCRIPT LANGUAGE: VBScript ':: SCRIPT NAME: RestartService.vbs '::
PURPOSE: To be used to Restart Symantec Service ':: CREATION DATE: 09/15/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, Dim objShell,
Install, Update, DELICON, Windows7_OS, XP_OS
'SET WORKSTATION NAME
strComputer = "."
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 7 Enterprise" then Seven()
'SETS UP
SECONDARY OS DETECTION IF NEEDED Set filesys =
CreateObject("Scripting.FileSystemObject") Windows7_OS = "C:\Users\Public"
XP_OS = "C:\Documents and Settings"
'SECONDARY DETECTION LOGIC If
filesys.FolderExists(Windows7_OS) then Seven() If filesys.FolderExists(XP_OS)
then XP() if OSDetect <> "Microsoft Windows 7 Enterprise" then XP()
'W I N D O W S X P Sub XP ON ERROR RESUME NEXT
Set objShell
= CreateObject("WScript.Shell")
'BEGIN PROCESSING 'STEP 1
TurnOffSMC = "cmd /c " & CHR(34)&"%programfiles%\Symantec\Symantec Endpoint Protection\Smc.exe"
& CHR(34)&" -stop -p <<<PASSWORDHERE>>>" 'msgbox TurnOffSMC Err.Number =
objShell.Run (TurnOffSMC,0,True) ErrorCode1 = Err.Number Err.Number = ""
WScript.Sleep 1000 'msgbox "step1 " & ErrorCode1 'WScript.Quit(0)
'STEP 2 DeleteSephwidXML = "cmd /c del /q " & CHR(34)&"%programfiles%\Common
Files\Symantec Shared\HWID\sephwid.xml" & CHR(34) 'msgbox DeleteSephwidXML
Err.Number = objShell.Run (DeleteSephwidXML,0,True) ErrorCode2 = Err.Number
Err.Number = "" WScript.Sleep 1000 'msgbox "step2 " & ErrorCode2
'WScript.Quit(0)
'STEP 3 EditRegKey = "cmd /c
%windir%\system32\REG.exe ADD "& chr(34)&"HKLM\ Software\Symantec\Symantec
Endpoint Protection\SMC\Sylink\Sylink"&chr(34)&" /v HardwareID /t REG_SZ /d
" & CHR(34)&CHR(34)&" /f" 'msgbox EditRegKey Err.Number = objShell.Run
(EditRegKey,0,True) ErrorCode3 = Err.Number Err.Number = ""
WScript.Sleep 1000 'msgbox "step3 " & ErrorCode3 'WScript.Quit(0)
'STEP 4 TurnOnSMC = "cmd /c " & CHR(34)&"%programfiles%\Symantec\Symantec
Endpoint Protection\Smc.exe" & CHR(34)&" -start -p <<<PASSWORDHERE>>>"
'msgbox TurnOnSMC Err.Number = objShell.Run (TurnOnSMC,0,True) ErrorCode4
= Err.Number Err.Number = "" WScript.Sleep 1000 'msgbox "step4 " &
ErrorCode4 'WScript.Quit(0)
Set filesys =
CreateObject("Scripting.FileSystemObject") PolicyChecker =
"%programfiles%\Common Files\Symantec Shared\HWID\sephwid.xml"
If NOT
filesys.FileExists(PolicyChecker) THEN WScript.Sleep 2000 'STEP 3
EditRegKey = "cmd /c %windir%\system32\REG.exe ADD "& chr(34)&"HKLM\Software\
Symantec\Symantec Endpoint Protection\SMC\Sylink\Sylink"&chr(34)&" /v HardwareID
/t REG_SZ /d " & CHR(34)&CHR(34)&" /f" 'msgbox EditRegKey Err.Number =
objShell.Run (EditRegKey,0,True) ErrorCode3 = Err.Number Err.Number = ""
WScript.Sleep 2000 'msgbox "step3 " & ErrorCode3 'WScript.Quit(0)
'STEP 4 TurnOnSMC = "cmd /c " & CHR(34)&"%programfiles%\Symantec\Symantec
Endpoint Protection\Smc.exe" & CHR(34)&" -start -p <<<PASSWORDHERE>>>"
'msgbox TurnOnSMC Err.Number = objShell.Run (TurnOnSMC,0,True) ErrorCode4
= Err.Number Err.Number = "" WScript.Sleep 2000 'msgbox "step4 " &
ErrorCode4 'WScript.Quit(0) End if
'msgbox "step5 " &
ErrorCode5
'HANDLES FINAL ERRORCODE if ErrorCode4 = 3010 then
ErrorCode4 = 0 '''if ErrorCode2 = 1602 then ErrorCode2 = 0
WScript.Quit(ErrorCode4) End Sub
'W I N D O W S 7 Sub
SEVEN() ON ERROR RESUME NEXT
Set objShell =
CreateObject("WScript.Shell")
'BEGIN PROCESSING 'STEP 1
TurnOffSMC = "cmd /c " & CHR(34)&"%programfiles%\Symantec\Symantec Endpoint
Protection\Smc.exe" & CHR(34)&" -stop -p <<<PASSWORDHERE>>>" 'msgbox
TurnOffSMC Err.Number = objShell.Run (TurnOffSMC,0,True) ErrorCode1 =
Err.Number Err.Number = "" WScript.Sleep 1000 'msgbox "step1 " &
ErrorCode1 'WScript.Quit(0)
'STEP 2 DeleteSephwidXML = "cmd /c del
/q " & CHR(34)&"%programfiles%\Common Files\Symantec Shared\HWID\sephwid.xml" &
CHR(34) 'msgbox DeleteSephwidXML Err.Number = objShell.Run
(DeleteSephwidXML,0,True) ErrorCode2 = Err.Number Err.Number = ""
WScript.Sleep 1000 'msgbox "step2 " & ErrorCode2 'WScript.Quit(0)
'STEP 3 EditRegKey = "cmd /c %windir%\system32\REG.exe ADD "& chr(34)&"HKLM\
Software\Symantec\Symantec Endpoint Protection\SMC\Sylink\Sylink"&chr(34)&"
/v HardwareID /t REG_SZ /d " & CHR(34)&CHR(34)&" /f" 'msgbox EditRegKey
Err.Number = objShell.Run (EditRegKey,0,True) ErrorCode3 = Err.Number
Err.Number = "" WScript.Sleep 1000 'msgbox "step3 " & ErrorCode3
'WScript.Quit(0)
'STEP 4 TurnOnSMC = "cmd /c " &
CHR(34)&"%programfiles%\Symantec\Symantec Endpoint Protection\Smc.exe"
& CHR(34)&" -start -p <<<PASSWORDHERE>>>" 'msgbox TurnOnSMC Err.Number =
objShell.Run (TurnOnSMC,0,True) ErrorCode4 = Err.Number Err.Number = ""
WScript.Sleep 1000 'msgbox "step4 " & ErrorCode4 'WScript.Quit(0)
Set filesys = CreateObject("Scripting.FileSystemObject") PolicyChecker =
"%programfiles%\Common Files\Symantec Shared\HWID\sephwid.xml"
If NOT
filesys.FileExists(PolicyChecker) THEN WScript.Sleep 2000 'STEP 3
EditRegKey = "cmd /c %windir%\system32\REG.exe ADD "& chr(34)&"HKLM\Software\
Symantec\Symantec Endpoint Protection\SMC\Sylink\Sylink"&chr(34)&" /v HardwareID
/t REG_SZ /d " & CHR(34)&CHR(34)&" /f" 'msgbox EditRegKey Err.Number =
objShell.Run (EditRegKey,0,True) ErrorCode3 = Err.Number Err.Number = ""
WScript.Sleep 2000 'msgbox "step3 " & ErrorCode3 'WScript.Quit(0)
'STEP 4 TurnOnSMC = "cmd /c " & CHR(34)&"%programfiles%\Symantec\Symantec
Endpoint Protection\Smc.exe" & CHR(34)&" -start -p <<<PASSWORDHERE>>>"
'msgbox TurnOnSMC Err.Number = objShell.Run (TurnOnSMC,0,True) ErrorCode4
= Err.Number Err.Number = "" WScript.Sleep 2000 'msgbox "step4 " &
ErrorCode4 'WScript.Quit(0) End if
'HANDLES FINAL ERRORCODE
if ErrorCode4 = 3010 then ErrorCode4 = 0 '''if ErrorCode2 = 1602 then
ErrorCode2 = 0 WScript.Quit(ErrorCode4) End Sub
![bar1](http://eddiejackson.net/web_images/lightgraybar.bmp)
|
![bar1](http://eddiejackson.net/web_images/lightgraybar.bmp)
Δ
Wednesday, September 8th 2010
![bar1](http://eddiejackson.net/web_images/lightgraybar.bmp)
Δ
Collect PST Information And Send To LANDesk
How to collect local PST information and return data to LANDesk
[Link to
files]
How would you use LANDesk to find the name, size, and path of PST files in your organization? This
VBScript is an excellent example of how LANDesk Management Suite can be
extended with scripts to gather and query just about any random chunk of
data. Distribute the contents of
the Files.zip
to your client's c:\Program Files\Landesk\ldclient directory. Send a
script to extract the files.zip in the LDClient directory and you can
automatically run an inventory scan using the ldiscn32.exe in your script.
Then create a query from the Management Suite to query your enterprise machines
using Custom Data - Email PST.
If you
want to test the files before deploying via LANDesk, just copy the
ScanPST.vbs file to your LDClient folder, and run. It will create the
pstreport.dat, and depending on the on the speed of your machine, it will
eventually populate the results to the .dat file. You can monitor the
process in task manager as wmiprvse.exe - NETWORK SERVICE. Once the
process is complete, force an inventory scan, and watch your inventory
results populate your new PST information into the SQL database.
VBScript: scanpst.vbs
![bar1](http://eddiejackson.net/web_images/lightgraybar.bmp)
'============================================================ 'L A N G U A G
E 'VBScript ' 'S C R I P T N A M E 'ScanPST.VBS ' 'P U R P O
S E 'To scan for PSTs and return report to LANDesk ' 'U S A G E '
'A U T H O R 'Eddie S. Jackson ' 'D A T E C R E A T E D
'09/09/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 '
'============================================================
'============================================================ ' S T A T I C V
A R I A B L E S '============================================================
'SCAN FILES IN SUB-FOLDERS? '[options]- true or false
includeSubfolders = true
'FILES WITH EXTENSIONS PROVIDED IN THE LIST
BELOW WILL BE DSCANNED '[options]- any file type including multiple files
separated by a comma, no spaces strExtensionsToScan = "pst"
'MAX FILE
AGE IN DAYS. FILES OLDER THAN THIS WILL NOT BE RETURNED. '[options]- any
amount of days minAge = 3650 '10 years
'SETS LDCLIENT PATH
LANDeskPath = "C:\Progra~1\LANDesk\LDClient\"
'SETS DAT FILE PATH FOR
PSTREPORT.DAT PstDatFile = LANDeskPath & "pstreport.dat"
Set objShell
= CreateObject("WScript.Shell") Set objFSO =
CreateObject("Scripting.FileSystemObject") set filesys =
CreateObject("Scripting.FileSystemObject")
Const ForWriting = 2 Const
ForAppending = 8 Const ForReading = 1
'DELETES DAT FILE IF EXISTS
If filesys.FileExists(PstDatFile) Then on error resume next
filesys.DeleteFile PstDatFile end if
'CREATES DAT FILE IF NOT EXISTS
If NOT filesys.FileExists(PstDatFile) Then on error resume next Set
objFile = objFSO.CreateTextFile(PstDatFile) objFile.Close end if
'DISABLED 'Network Option ''Set objTextFile =
objFSO.OpenTextFile("c:\computers.txt", ForReading)
Set objLogFile =
objFSO.OpenTextFile(PstDatFile, ForAppending, True)
'============================================================
'============================================================ ' D Y N A M I C V A R I A B L E S
'============================================================ 'LOOP THROUGH
TEXT FILE 'DISABLED 'Network Option ''Do Until
objTextFile.AtEndOfStream '#'ON ERROR RESUME NEXT
'COMPUTER NAME TO
SCAN FILES 'DISABLED 'Network Option ''strComputer =
objTextFile.Readline|
'LANDesk Option strComputer = "."
'FOLDER
TO SCAN FILES '[options]- any folder 'DISABLED 'Network Option
''strFolder = "\\" & strComputer & "\c$\Documents and Settings\"
'LANDesk
Option strFolder = "c:\"
'============================================================
'============================================================ ' M A I N
'============================================================ 'calls sub
on error resume next ScanFiles strFolder,strExtensionsToScan, minAge,
includeSubFolders WScript.Quit(0)
'DISABLED 'Network Option
''Loop '============================================================
'============================================================ ' S U B
R O U T I N E TO S C A N F O R P S T F I L E S
'============================================================ 'sub begins
here sub ScanFiles(byval strDirectory,byval strExtensionsToScan,byval
minAge,includeSubFolders) ON ERROR RESUME NEXT DIM objFolder,
objSubFolder, objFile DIM strExt
Set objFolder =
objFSO.GetFolder(strDirectory)
for each objFile in objFolder.Files
'msgbox objFile.Name ON ERROR RESUME NEXT for each strExt in
SPLIT(UCASE(strExtensionsToScan),",") if
RIGHT(UCASE(objFile.Path),LEN(strExt)+1) = "." & strExt then ON ERROR RESUME
NEXT
IF objFile.DateLastModified > (Now - minAge) THEN on error resume
next
'THIS WILL MAKE SURE NO EXTRA WHITE LINES GET ADDED TO END OF DAT
FILE, WHICH CAUSES ERRORS if strExt = "" then objLogFile.WriteLine.Close
WScript.Quit(0) end if
'TRIMS ANY WHITE SPACE FROM VARIABLES
objFile.Name = trim(objFile.Name) objFile.Size = trim(objFile.Size)
objFile.Path = trim(objFile.Path)
'WRITES DATA TO DAT FILE
objLogFile.WriteLine("Custom Data - " & "Email PST - " & objFile.Name & " - Name
= " & objFile.Name) objLogFile.WriteLine("Custom Data - " & "Email PST - " &
objFile.Name & " - Size = " & objFile.Size) objLogFile.WriteLine("Custom Data
- " & "Email PST - " & objFile.Name & " - Path = " & objFile.Path) '<node of
the inventory> - <node of the inventory> - ..... - <value name> = <the value>
'strTotalSpace = strTotalSpace + objFile.Size 'objLogFile.WriteLine("Custom
Data - " & "Email PST - " & objFile.Name & " - Total Disk Size = " &
strTotalSpace)
exit for
END IF end if next next if
includeSubFolders = true then ' Recursive scan ON ERROR RESUME NEXT for
each objSubFolder in objFolder.SubFolders ON ERROR RESUME NEXT ScanFiles
objSubFolder.Path,strExtensionsToScan,minAge, includeSubFolders
next
end if
end sub
'========================================================
![bar1](http://eddiejackson.net/web_images/lightgraybar.bmp)
|
LDSCNHLP.INI file:
[EXECUTE WIN16]
[EXECUTE WIN32] LAUNCH1=cscript.exe C:\Progra~1\LANDesk\LDClient\scanpst.vbs
TIMEOUT1=600
[DATA FILES]
DATANOPREPEND1=C:\PROGRA~1\LANDesk\LDClient\pstreport.DAT
DATA2=C:\PROGRA~1\LANDesk\LDClient\LDCUSTOM.DAT
Δ
Use General Time Of Day In Your Scripts
How to return the general time of day to be used to
execute specific code
VBScript
![bar1](http://eddiejackson.net/web_images/lightgraybar.bmp)
if TimeOfDay = "morning" then 'yourcode here end if
'THIS FUNCTION
RETURNS GENERAL TIME OF DAY; MORNING, AFTERNOON, EVENING Function TimeOfDay()
on error resume next Dim h 'create variable that will store the hour
'EXAMPLE 'msgbox TimeOfDay()
h=hour(now) 'pass in the date and time to
the hour function as a parameter
If h<12 then 'msgbox "morning!"
TimeOfDay = "morning" ElseIf h<18 then 'msgbox "afternoon!" TimeOfDay =
"afternoon" else 'msgbox "evening!" TimeOfDay = "evening" end if
End function
![bar1](http://eddiejackson.net/web_images/lightgraybar.bmp)
|
Δ
Simple Backup Utility In Shell
How to backup all the important information to a specified
drive
Shell
![bar1](http://eddiejackson.net/web_images/lightgraybar.bmp)
::INSTRUCTIONS ::RESTART COMPUTER ::LOG IN AS LOCAL ADMIN OR ANOTHER
ACCOUNT OTHER THAN THE ONE YOU'RE BACKING UP ::RUN THIS SCRIPT
@Echo off ::@color 3a @color 0a title Backup/Export Data Utility
::EXCLUDE THESE FILE EXTENSIONS FROM BACKUP echo .pst >
%temp%\exclude.txt rem PST backup happens separately echo .tmp >>
%temp%\exclude.txt echo .dat >> %temp%\exclude.txt echo .ini >>
%temp%\exclude.txt echo .uccplog >> %temp%\exclude.txt echo .db >>
%temp%\exclude.txt echo .exe >> %temp%\exclude.txt echo .bat >>
%temp%\exclude.txt echo .cmd >> %temp%\exclude.txt echo .vbs >>
%temp%\exclude.txt echo .com >> %temp%\exclude.txt echo .pol >>
%temp%\exclude.txt ::echo .vbs >> %temp%\exclude.txt
:DRIVE
::BACKUP TO WHAT DRIVE cls set /p BACKUP=Enter Drive letter to backup data
(example [c:]) if /I "%BACKUP%"=="c:" (GOTO DRIVEYN) if /I
"%BACKUP%"=="d:" (GOTO DRIVEYN) if /I "%BACKUP%"=="e:" (GOTO DRIVEYN) if
/I "%BACKUP%"=="f:" (GOTO DRIVEYN) if /I "%BACKUP%"=="g:" (GOTO DRIVEYN)
if /I "%BACKUP%"=="h:" (GOTO DRIVEYN) if /I "%BACKUP%"=="i:" (GOTO DRIVEYN)
if /I "%BACKUP%"=="j:" (GOTO DRIVEYN) if /I "%BACKUP%"=="k:" (GOTO DRIVEYN)
if /I "%BACKUP%"=="l:" (GOTO DRIVEYN) if /I "%BACKUP%"=="m:" (GOTO DRIVEYN)
if /I "%BACKUP%"=="n:" (GOTO DRIVEYN) if /I "%BACKUP%"=="o:" (GOTO DRIVEYN)
if /I "%BACKUP%"=="p:" (GOTO DRIVEYN) if /I "%BACKUP%"=="q:" (GOTO DRIVEYN)
if /I "%BACKUP%"=="r:" (GOTO DRIVEYN) if /I "%BACKUP%"=="s:" (GOTO DRIVEYN)
if /I "%BACKUP%"=="t:" (GOTO DRIVEYN) if /I "%BACKUP%"=="u:" (GOTO DRIVEYN)
if /I "%BACKUP%"=="v:" (GOTO DRIVEYN) if /I "%BACKUP%"=="w:" (GOTO DRIVEYN)
if /I "%BACKUP%"=="x:" (GOTO DRIVEYN) if /I "%BACKUP%"=="y:" (GOTO DRIVEYN)
if /I "%BACKUP%"=="z:" (GOTO DRIVEYN) goto DRIVE
:DRIVEYN cls
set /p yn=Are you sure you want to use [%BACKUP%] [y/n]? if "%yn%"=="" (echo
Not entry) & (GOTO DRIVE) if /I "%yn%"=="n" (GOTO DRIVE) if /I
"%yn%"=="y" (GOTO GETUNAME) else (echo Entry not y or n!) & (GOTO DRIVE)
:GETUNAME cls set /p UNAME=Enter Username to backup up data:
if /I %UNAME%=="" exit cls set /p yn=Are you sure you want backup data for
{{{ %UNAME% }}} [y/n]? if "%yn%"=="" (echo Not entry) & (GOTO GETUNAME)
if /I "%yn%"=="n" (GOTO GETUNAME) if /I "%yn%"=="y" (GOTO PHASE_1) else (echo
Entry not y or n!) & (GOTO GETUNAME)
:PHASE_1 cls if not exist
c:\docume~1\%UNAME% echo User not found & pause & exit md
"%BACKUP%\%COMPUTERNAME%\%UNAME%" md "%BACKUP%\%COMPUTERNAME%\%UNAME%\PSTs"
md "%BACKUP%\%COMPUTERNAME%\%UNAME%\PSTs\AllProfiles" md
"%BACKUP%\%COMPUTERNAME%\%UNAME%\PSTs\CDrive" md
"%BACKUP%\%COMPUTERNAME%\%UNAME%\misc"
::GOTO PHASE_5
cls Echo
Creating User Profile file log... dir /b /s "c:\docume~1\%UNAME%\*.*"
>"%BACKUP%\%COMPUTERNAME%\%UNAME%\UserProfile_Log.txt" cls Echo Creating
Complete System file log... dir /b /s c:\*.*
>"%BACKUP%\%COMPUTERNAME%\%UNAME%\Complete_File_Log.txt" cls echo PHASE 1
Complete! c:\windows\system32\ping.exe -n 5 127.0.0.1>nul
:PHASE_2
cls Echo Creating directory structure... xcopy "c:\documents and
settings\%UNAME%\*.*" "%BACKUP%\%COMPUTERNAME%\%UNAME%" /t /i /e /s cls
echo Created directory structure. PHASE 2 Complete!
c:\windows\system32\ping.exe -n 5 127.0.0.1>nul
:PHASE_3 cls
Echo Backuping up User Profile... xcopy "c:\documents and
settings\%UNAME%\*.*" "%BACKUP%\%COMPUTERNAME%\%UNAME%" /s /e /h /r /v /c /y /f
/i /EXCLUDE:%temp%\exclude.txt cls echo User Profile has been backed up.
PHASE 3 Complete! c:\windows\system32\ping.exe -n 5 127.0.0.1>nul
:PHASE_4 cls Echo Mining for other data... @xcopy "c:\*.txt"
"%BACKUP%\%COMPUTERNAME%\%UNAME%\misc" /h /r /v /c /y /f /I /g @xcopy
"c:\*.doc" "%BACKUP%\%COMPUTERNAME%\%UNAME%\misc" /h /r /v /c /y /f /I /g
@xcopy "c:\*.ppt" "%BACKUP%\%COMPUTERNAME%\%UNAME%\misc" /h /r /v /c /y /f /I /g
@xcopy "c:\*.xls" "%BACKUP%\%COMPUTERNAME%\%UNAME%\misc" /h /r /v /c /y /f /I /g
@xcopy "c:\*.mdb" "%BACKUP%\%COMPUTERNAME%\%UNAME%\misc" /h /r /v /c /y /f /I /g
@xcopy "c:\*.docx" "%BACKUP%\%COMPUTERNAME%\%UNAME%\misc" /h /r /v /c /y /f /I
/g @xcopy "c:\*.pptx" "%BACKUP%\%COMPUTERNAME%\%UNAME%\misc" /h /r /v /c /y
/f /I /g @xcopy "c:\*.xlsx" "%BACKUP%\%COMPUTERNAME%\%UNAME%\misc" /h /r /v
/c /y /f /I /g @xcopy "c:\*.jpg" "%BACKUP%\%COMPUTERNAME%\%UNAME%\misc" /h /r
/v /c /y /f /I /g @xcopy "c:\*.bmp" "%BACKUP%\%COMPUTERNAME%\%UNAME%\misc" /h
/r /v /c /y /f /I /g @xcopy "c:\*.tif" "%BACKUP%\%COMPUTERNAME%\%UNAME%\misc"
/h /r /v /c /y /f /I /g
@xcopy "c:\windows\*.txt"
"%BACKUP%\%COMPUTERNAME%\%UNAME%\misc" /h /r /v /c /y /f /I /g @xcopy
"c:\windows\*.doc" "%BACKUP%\%COMPUTERNAME%\%UNAME%\misc" /h /r /v /c /y /f /I
/g @xcopy "c:\windows\*.ppt" "%BACKUP%\%COMPUTERNAME%\%UNAME%\misc" /h /r /v
/c /y /f /I /g @xcopy "c:\windows\*.xls"
"%BACKUP%\%COMPUTERNAME%\%UNAME%\misc" /h /r /v /c /y /f /I /g @xcopy
"c:\windows\*.mdb" "%BACKUP%\%COMPUTERNAME%\%UNAME%\misc" /h /r /v /c /y /f /I
/g @xcopy "c:\windows\*.docx" "%BACKUP%\%COMPUTERNAME%\%UNAME%\misc" /h /r /v
/c /y /f /I /g @xcopy "c:\windows\*.pptx"
"%BACKUP%\%COMPUTERNAME%\%UNAME%\misc" /h /r /v /c /y /f /I /g @xcopy
"c:\windows\*.xlsx" "%BACKUP%\%COMPUTERNAME%\%UNAME%\misc" /h /r /v /c /y /f /I
/g @xcopy "c:\windows\*.jpg" "%BACKUP%\%COMPUTERNAME%\%UNAME%\misc" /h /r /v
/c /y /f /I /g @xcopy "c:\windows\*.bmp"
"%BACKUP%\%COMPUTERNAME%\%UNAME%\misc" /h /r /v /c /y /f /I /g @xcopy
"c:\windows\*.tif" "%BACKUP%\%COMPUTERNAME%\%UNAME%\misc" /h /r /v /c /y /f /I
/g cls echo Mining for other data is done. PHASE 4 Complete!
c:\windows\system32\ping.exe -n 5 127.0.0.1>nul
:PHASE_5 cls
Echo Searching for PSTs... Echo. @Echo off xcopy
"c:\docume~1\%UNAME%\*.pst" "%BACKUP%\%COMPUTERNAME%\%UNAME%\PSTs" /s /h /r /v
/c /y /f /I /g xcopy "c:\docume~1\*.pst"
"%BACKUP%\%COMPUTERNAME%\%UNAME%\PSTs\AllProfiles" /s /h /r /v /c /y /f /I /g
xcopy "c:\*.pst" "%BACKUP%\%COMPUTERNAME%\%UNAME%\PSTs\CDrive" /h /r /v /c /y /f
/I /g xcopy "c:\Windows\*.pst" "%BACKUP%\%COMPUTERNAME%\%UNAME%\PSTs\CDrive"
/h /r /v /c /y /f /I /g xcopy "c:\Windows\system32\*.pst"
"%BACKUP%\%COMPUTERNAME%\%UNAME%\PSTs\CDrive" /h /r /v /c /y /f /I /g cls
echo Searching for PSTs is done. PHASE 5 Complete!
c:\windows\system32\ping.exe -n 5 127.0.0.1>nul cls Echo Backup
Complete!!! Echo. pause exit
![bar1](http://eddiejackson.net/web_images/lightgraybar.bmp)
|
![bar1](http://eddiejackson.net/web_images/lightgraybar.bmp)
Δ
Tuesday, September 7th 2010
![bar1](http://eddiejackson.net/web_images/lightgraybar.bmp)
Δ
Qfiniti Deployment
How to deploy qfiniti to your enterprise using vbscript
VBScript: Install
![bar1](http://eddiejackson.net/web_images/lightgraybar.bmp)
'::
******************************************************************************
':: SCRIPT LANGUAGE: VBScript ':: SCRIPT NAME: QfinitiInstall.vbs '::
PURPOSE: To be used to Install Qfiniti ':: CREATION DATE: 09/07/2010 '::
LAST MODIFIED: ':: DIRECTIONS: Send to client workstation ':: AUTHOR:
Eddie Jackson ':: EMAIL: MrNetTek2000@yahoo.com '::
*****************************************************************************
'ON ERROR RESUME NEXT Dim filesys, strComputer, OSDetect, objWMIService,
colInstances, sUser, strUser, objShell, Install, Update, DELICON
'DISABLED
FEATURE POLICY 'set filesys = createobject("scripting.filesystemobject")
'FilterFile = "c:\Program Files\none\none.exe" 'If
filesys.FileExists(FilterFile) THEN 'WScript.Quit(0) 'End if
'SET WORKSTATION NAME strComputer = "."
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 7
Enterprise" then Seven()
'SETS UP SECONDARY OS DETECTION IF NEEDED Set
filesys = CreateObject("Scripting.FileSystemObject") Windows7_OS =
"C:\Users\Public" XP_OS = "C:\Documents and Settings"
'SECONDARY
DETECTION LOGIC If filesys.FolderExists(Windows7_OS) then Seven() If
filesys.FolderExists(XP_OS) then XP() if OSDetect <> "Microsoft
Windows 7 Enterprise" then XP()
'W
I N D O W S X P Sub XP 'ON ERROR RESUME NEXT
'DISABLE: RETURN
CURRENT USER ' sUser = ConsoleUser(".") ' strUser = Trim(sUser)
'MsgBox sUser
Set objShell = CreateObject("WScript.Shell")
'TEMPORARILY TURNS OFF AUTOMATIC UPDATES objShell.Run "cmd /c net stop
wuauserv",0,True
'DISABLED MAKE DIRECTORY 'objShell.Run "cmd /c md " &
chr(34) & "%ProgramFiles%\Iron Mountain" & chr(34),0,True
'DISABLED SET
FOLDER PERMISSIONS 'objShell.Run "c:\windows\system32\cacls.exe" & " " &
chr(34) & "%ProgramFiles%\Iron Mountain" & chr(34) & " " & "/e /g
everyone:f",0,True
'INSTALLS APPLICATION Install = "setup.exe /s
/v"&CHR(34)&" /qn ALLUSERS=\"&CHR(34)&"1\" & CHR(34)&"
ADDLOCAL=\"&CHR(34)&"Supervisor,Agent,G729Codec\"&CHR(34)&"
REMOVE=\"&CHR(34)&"SoapToolKit,SystemMonitor,SystemConfiguration,AgentAssistAdminClient\"&CHR(34)&"
TYPE=\"& CHR(34)&"WINDOWS_AUTO\"&CHR(34)& "
WEBSERVER=\"&CHR(34)&"THEWEBSERVER\"&CHR(34)&CHR(34) 'msgbox Install
Err.Number = objShell.Run (Install,0,True) ErrorCode1 = Err.Number 'msgbox
"step1 " & ErrorCode1 'WScript.Quit(0)
'UPDATES APPLICATION Update
= "cmd /c c:\windows\system32\msiexec.exe /qn /p "& CHR(34) & "Q35C1005.msp" &
CHR(34) 'msgbox Update Err.Number = objShell.Run (Update,0,True)
ErrorCode2 = Err.Number 'msgbox "step2 " & ErrorCode2 'WScript.Quit(0)
'EXTRACTS REQUIRED FILES TO %PROGRAMFILES%\Qfiniti\Qfiniti Desktop
Err.Number = objShell.Run ("extract.exe",9,True) ErrorCode3 = Err.Number
'msgbox "step3 " & ErrorCode3 'WScript.Quit(0)
'DELETE DESKTOP ICON
FROM ALL USERS DELICON = "cmd /c del /q " &
chr(34)&"%ALLUSERSPROFILE%\Desktop\Qfiniti Agent Assist*"&chr(34) Err.Number
= objShell.Run (DELICON,0,False) ErrorCode4 = Err.Number 'msgbox "step4 "
& ErrorCode4 'WScript.Quit(0)
'TURNS ON AUTOMATIC UPDATES
objShell.Run "cmd /c net start wuauserv",0,True
'HANDLES FINAL ERRORCODE
if ErrorCode2 = 3010 then ErrorCode2 = 0 WScript.Quit(ErrorCode2) End Sub
'W I N D O W S 7 Sub SEVEN() 'ON ERROR RESUME NEXT
'DISABLE: RETURN CURRENT USER ' sUser = ConsoleUser(".") ' strUser =
Trim(sUser)
'MsgBox sUser
Set objShell =
CreateObject("WScript.Shell") 'TEMPORARILY TURNS OFF AUTOMATIC UPDATES
objShell.Run "cmd /c net stop wuauserv",0,True
'DISABLED MAKE DIRECTORY
'objShell.Run "cmd /c md " & chr(34) & "%ProgramFiles%\Iron Mountain" &
chr(34),0,True
'DISABLED SET FOLDER PERMISSIONS 'objShell.Run
"c:\windows\system32\cacls.exe" & " " & chr(34) & "%ProgramFiles%\Iron Mountain"
& chr(34) & " " & "/e /g everyone:f",0,True
'INSTALLS APPLICATION
Install = "setup.exe /s /v"&CHR(34)&" /qn ALLUSERS=\"&CHR(34)&"1\" & CHR(34)&"
ADDLOCAL=\"&CHR(34)&"Supervisor,Agent,G729Codec\"&CHR(34)&"
REMOVE=\"&CHR(34)&"SoapToolKit,SystemMonitor,SystemConfiguration,AgentAssistAdminClient\"&CHR(34)&"
TYPE=\"& CHR(34)&"WINDOWS_AUTO\"&CHR(34)& "
WEBSERVER=\"&CHR(34)&"THEWEBSERVER\"&CHR(34)&CHR(34) 'msgbox Install
Err.Number = objShell.Run (Install,0,True) ErrorCode1 = Err.Number 'msgbox
"step1 " & ErrorCode1 'WScript.Quit(0)
'UPDATES APPLICATION Update
= "cmd /c c:\windows\system32\msiexec.exe /qn /p "& CHR(34) & "Q35C1005.msp" &
CHR(34) 'msgbox Update Err.Number = objShell.Run (Update,0,True)
ErrorCode2 = Err.Number 'msgbox "step2 " & ErrorCode2 'WScript.Quit(0)
'EXTRACTS REQUIRED FILES TO %PROGRAMFILES%\Qfiniti\Qfiniti Desktop
Err.Number = objShell.Run ("extract.exe",9,True) ErrorCode3 = Err.Number
'msgbox "step3 " & ErrorCode3 'WScript.Quit(0)
'DELETE DESKTOP ICON
FROM ALL USERS DELICON = "cmd /c del /q " &
chr(34)&"%ALLUSERSPROFILE%\Desktop\Qfiniti Agent Assist*"&chr(34) Err.Number
= objShell.Run (DELICON,0,False) ErrorCode4 = Err.Number msgbox "step4 " &
ErrorCode4 'WScript.Quit(0)
'TURNS ON AUTOMATIC UPDATES
objShell.Run "cmd /c net start wuauserv",0,True
'HANDLES FINAL ERRORCODE
if ErrorCode2 = 3010 then ErrorCode2 = 0 WScript.Quit(ErrorCode2) End Sub
'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 ConsoleUser = sUser End If Next End Function
![bar1](http://eddiejackson.net/web_images/lightgraybar.bmp)
|
![bar1](http://eddiejackson.net/web_images/lightgraybar.bmp)
Δ
Friday, September 3rd 2010
![bar1](http://eddiejackson.net/web_images/lightgraybar.bmp)
Δ
Assign Dir /b /s *.exe To A Variable
How to assign each .exe name to a variable and include
logging
Shell
![bar1](http://eddiejackson.net/web_images/lightgraybar.bmp)
@Echo off for /f "delims=" %%a in ('dir /b /s *.exe') do ( date /t
%%a>>c:\drivers\log.txt time /t %%a>>c:\drivers\log.txt echo Started
%%a>>c:\drivers\log.txt ::notepad.exe /s rem %%a /s time /t
%%a>>c:\drivers\log.txt echo Ended %%a>>c:\drivers\log.txt echo.>>
c:\drivers\log.txt )
![bar1](http://eddiejackson.net/web_images/lightgraybar.bmp)
|
![bar1](http://eddiejackson.net/web_images/lightgraybar.bmp)
Δ
Thursday, September 2nd 2010
![bar1](http://eddiejackson.net/web_images/lightgraybar.bmp)
Δ
Remotely Execute Process In VBScript
How to launch a process remotely in vbscript; works like
psexec.exe.
VBScript
![bar1](http://eddiejackson.net/web_images/lightgraybar.bmp)
'CALL THE APPLICATION FROM A SCRIPT THAT USES THE WIN32_PROCESS AND
WIN32_PROCESSSTARTUP CLASSES. 'on error resume next
Const
SW_SHOWNORMAL = 1 Const SW_HIDE = 0 Const SW_NORMAL = 1 Const
SW_SHOWMINIMIZED = 2 Const SW_SHOWMAXIMIZED = 3 Const SW_MAXIMIZE = 3
Const SW_SHOWNOACTIVATE = 4 Const SW_SHOW = 5 Const SW_MINIMIZE = 6
Const SW_SHOWMINNOACTIVE = 7 Const SW_SHOWNA = 8 Const SW_RESTORE =
9 Const SW_SHOWDEFAULT = 10 Const SW_MAX = 10 Const SW_FORCEMINIMIZE
= 11
strComputer = "ComputerName" strCommand = "notepad.exe"
Set objWMIService = GetObject("winmgmts:" _ &
"{impersonationLevel=impersonate}!\\" _ & strComputer & "\root\cimv2")
' Configure the Notepad process to show a window Set objStartup =
objWMIService.Get("Win32_ProcessStartup") Set objConfig =
objStartup.SpawnInstance_ objConfig.ShowWindow = SW_HIDE
' Create
Notepad process Set objProcess = objWMIService.Get("Win32_Process")
intReturn = objProcess.Create _ (strCommand, Null, objConfig, intProcessID)
If intReturn <> 0 Then Wscript.Echo "Process could not be created." & _
vbNewLine & "Command line: " & strCommand & _ vbNewLine & "Return value: " &
intReturn Else Wscript.Echo "Process created." & _ vbNewLine & "Command
line: " & strCommand & _ vbNewLine & "Process ID: " & intProcessID End If
![bar1](http://eddiejackson.net/web_images/lightgraybar.bmp)
|
Δ
Terminate Process In VBScript
How to end a process in vbscript; works like taskkill.exe
VBScript
![bar1](http://eddiejackson.net/web_images/lightgraybar.bmp)
'USE THE WIN32_PROCESS CLASS AND THE TERMINATE METHOD. strComputer = "."
Set objWMIService = GetObject("winmgmts:" _ &
"{impersonationLevel=impersonate}!\\" _ & strComputer & "\root\cimv2")
Set colProcessList = objWMIService.ExecQuery _ ("Select * from
Win32_Process Where Name = 'Notepad.exe'") For Each objProcess in
colProcessList objProcess.Terminate() Next
![bar1](http://eddiejackson.net/web_images/lightgraybar.bmp)
|
Δ
Return The Owner Of A Process In VBScript
How to return the owner of a running process
VBScript
![bar1](http://eddiejackson.net/web_images/lightgraybar.bmp)
'USE THE WIN32_PROCESS CLASS AND THE GETOWNER METHOD. strComputer = "."
Set objWMIService = GetObject("winmgmts:" _ &
"{impersonationLevel=impersonate}!\\" _ & strComputer & "\root\cimv2")
Set colProcessList = objWMIService.ExecQuery _ ("Select * from
Win32_Process") For Each objProcess in colProcessList colProperties
= objProcess.GetOwner( _ strNameOfUser,strUserDomain) Wscript.Echo
"Process " & objProcess.Name _ & " is owned by " _ &
strUserDomain & "\" & strNameOfUser & "." Next
![bar1](http://eddiejackson.net/web_images/lightgraybar.bmp)
|
Δ
Message Dialog Box
How to change dialog icon in a message dialog box
VBScript
buttons
|
result
|
|
1
vbOK
|
3
vbAbort
|
4
vbRetry
|
5
vbIgnore
|
6
vbYes
|
7
vbNo
|
2
vbCancel
|
0 or
vbOKOnly
|
OK
|
. |
. |
. |
. |
. |
. |
1 or
vbOKCancel
|
OK
|
|
|
|
|
|
Cancel
|
2 or
vbAbortRetryIgnore
|
. |
Abort
|
Retry
|
Ignore
|
. |
. |
. |
3 or
vbYesNoCancel
|
|
|
|
|
Yes
|
No
|
Cancel
|
4 or
vbYesNo
|
. |
. |
. |
. |
Yes
|
.
|
. |
5 or
vbRetryCancel
|
|
|
Retry
|
|
|
|
Cancel
|
16 or
vbCritical
|
Stop icon.
|
32 or
vbQuestion
|
Question mark icon.
|
48 or
vbExclaimation
|
Exclaimation point icon.
|
64 or
vbInfomation
|
Infomation icon.
|
256 or
vbDefaultButton2
|
Sets the focus to the second button.
|
512 or
vbDefaultButton3
|
Sets the focus to the third button.
|
4096 or
vbSystemModal
|
Presents the dialog box in the foreground.
|
Δ
Logged-In Status VBScript Function
How to return logged in status
(useful if you only want scripts executing when a user is logged in)
VBScript
![bar1](http://eddiejackson.net/web_images/lightgraybar.bmp)
'On error resume next strComputer = "."
If
UserLoggedInStatus() = TRUE then msgbox "user IS logged in"
WScript.Quit(0) end if
If UserLoggedInStatus() = FALSE then msgbox
"user NOT logged in" WScript.Quit(0) end if
'THIS
FUNCTION RETURNS LOGGED IN STATUS WITH A TRUE '-FOR LOGGED IN OR FALSE-NOT
LOGGED IN Function UserLoggedInStatus() Dim LoggedInStatus, objWMIService,
colItems
'Example 'strComputer = "." 'If UserLoggedInStatus = TRUE
then msgbox "user IS logged in" 'If UserLoggedInStatus = FALSE then msgbox
"user NOT logged in"
Set objWMIService = GetObject("winmgmts:\\" &
strComputer & "\root\cimv2") Set colItems = objWMIService.ExecQuery("Select *
from Win32_ComputerSystem",,48)
For Each objItem in colItems
'Wscript.Echo objItem.UserName LoggedInStatus = trim(objItem.UserName) & ""
next
if LoggedInStatus = "" then 'msgbox "User NOT logged in"
UserLoggedInStatus = FALSE end if
if LoggedInStatus <> "" then
'msgbox "User IS logged in" UserLoggedInStatus = TRUE end if
Set objItem = Nothing Set colItems = Nothing Set objWMIService = Nothing
End function
![bar1](http://eddiejackson.net/web_images/lightgraybar.bmp) |
![bar1](http://eddiejackson.net/web_images/lightgraybar.bmp) |
|
About
I'm a Computer
Systems Engineer
Living and loving life ........................................
Author
...
|