Remove Old GINA & Install New GINA

Created to work with LANDesk. It removes an old GINA, and then installs new GINA by using installation snapshots of the 32/64 bit setups.

@Echo on
rem ——————————————————————
rem author Eddie Jackson
rem data 10/07/2013
rem info Uninstalls old GINA
rem info Installs new GINA
rem tested Works for 32bit/64bit OS
rem ——————————————————————

title Administrative Installation by Eddie Jackson
color 0a
set CurDir=%cd%

set UserN=%username%
if [%UserN%] EQU [] set UserN=landesk
if [%UserN%] EQU %computername% set UserN=landesk

rem DISABLED for “pull” files
rem if not “%1” == “” set temp=%1

c:\windows\system32\ping.exe -n 8 127.0.0.1>nul

rem kill open browsers
c:\windows\system32\taskkill /f /im iexplore.exe
c:\windows\system32\taskkill /f /im chrome.exe

rem create event log
EVENTCREATE /T INFORMATION /ID 777 /d “GINA 1.0 package installation STARTED by %UserN%”

rem uninstall 32bit old gina
c:\windows\system32\msiexec.exe /x {228906A7-8F1D-48FE-9286-056CDE2880A9} /qn /norestart
rem uninstall 64bit old gina
c:\windows\system32\msiexec.exe /x {50E9CF6B-28AF-444A-9618-4A948D536248} /qn /norestart

rem post uninstall cleanup
rem remove registry keys
%windir%\system32\REG.exe DELETE “HKEY_LOCAL_MACHINE\SOFTWARE\TheDotNetFactory” /f
%windir%\system32\REG.exe DELETE “HKEY_LOCAL_MACHINE\SOFTWARE\TheDotNetFactory” /f /reg:64

rem 64bit simple detection
if exist “C:\Program Files (x86)\LANDESK\LDClient\sdmcache” (
rem install 64bit new gina – contains snapshot
“%CurDir%\fim64.exe”
“C:\Program Files (x86)\LANDesk\LDClient\sdmcache\apps\misc\gina\fim64.exe”
rem change service from disabled to automatically start
sc.exe config “FIMPasswordReset” start= auto
goto :END
)

rem 32bit simple detection
if exist “C:\Program Files\LANDesk\LDClient\sdmcache” (
rem install 32bit new gina – contains snapshot
“%CurDir%\fim32.exe”
“C:\Program Files\LANDesk\LDClient\sdmcache\apps\misc\gina\fim32.exe”
goto :END
)

:END
rem registry stamp
%windir%\system32\REG.exe ADD “HKEY_LOCAL_MACHINE\SOFTWARE\MYSOFTWARE\GINA\1.0.0.0” /v InstallDate /d “%date% %time%” /t REG_SZ /f
%windir%\system32\REG.exe ADD “HKEY_LOCAL_MACHINE\SOFTWARE\MYSOFTWARE\GINA\1.0.0.0” /v InstalledBy /d “%UserN%” /t REG_SZ /f

rem create event log
EVENTCREATE /T INFORMATION /ID 777 /d “GINA 1.0 package installation COMPLETED SUCCESSFULLY!”

rem exit
exit /b 0

email me

Create a 64/32 bit Wrapper

If you are using Autoit, depending on whether you install AutoIt / Scite on a 64bit machine or a 32bit machine, your default wrapper settings are set to a specific Architecture. You can specify what Arch. you want your wrapper to deploy with by using the Autoit Directives #AutoIt3Wrapper_UseX64=x.

This can have an effect on how to write your registry.

If you use 64-bit wrapper (#AutoIt3Wrapper_UseX64=Y)

Then you can use the normal HKLM to write to the 64-bit registry

If you are using the 32-Bit wrapper (#AutoIt3Wrapper_UseX64=N)

http://community.landesk.com/support/message/74843

email me

Query Show & Hide Hidden File and Folder Setting

Created to return whether files and folders that are hidden can be seen or not.

rem Returns whether files are hidden or not

@echo off &setlocal
set “regkey=HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced”
for /f “tokens=2*” %%a in (‘reg query %regkey% /v Hidden^|find “REG_DWORD”‘) do set /a Hidden=%%b
for /f “tokens=2*” %%a in (‘reg query %regkey% /v ShowSuperHidden^|find “REG_DWORD”‘) do set /a SSuperHidden=%%b
if “%hidden%”==”1” (set /a hidden=2, SSuperHidden=0) else set /a hidden=1, SSuperHidden=1
reg add %regkey% /f /v Hidden /t REG_DWORD /d %hidden% >nul
reg add %regkey% /f /v ShowSuperHidden /t REG_DWORD /d %SSuperHidden% >nul
for /f “tokens=2*” %%a in (‘reg query %regkey% /v Hidden^|find “REG_DWORD”‘) do set /a Hidden=%%b
if “%hidden%”==”1” (echo NOT hidden.) else echo hidden.
endlocal
PAUSE

email me

Compare and Merge Specified Variables in Text Files

I created this to compare two text lists. When the MAC address matches up, the old and new computer are outputted to a third file (which was to be used for renaming new, randomly named machines back to their original names).

@Echo off
rem looks at 2 text files
rem the first text file contains mac address and old computer name
rem the second text file contains mac address and new computer name
rem the script runs and matches up the old name and new name and
rem outputs that data to a third text file
Title Administrative Compare and Output
color 0a

REM —————————————————————————————————————————–
for /f “tokens=1,2 delims=,” %%a in (FILE1.txt) do (
for /f “tokens=1,2 delims=,” %%c in (FILE2.txt) do (
echo COMPARE MAC1-%%a to MAC2-%%c
if %%a == %%c echo SUCCESS! && echo %%b %%d & echo %%b,%%d>>computers.txt

rem timing, remove to speed up
ping -n 2 127.0.0.1>nul
)
)
REM —————————————————————————————————————————–
echo COMPLETE!
pause

Basic illustration of what happens

email me

Download Files from Website

email me

I created these scripts to download files from a website. 

Script 1

Dim varHTTP, varBinaryString, varFileName, varLink

Set varHTTP = CreateObject("Microsoft.XMLHTTP")
Set varBinaryString = CreateObject("Adodb.Stream")

varFileName = "YourFileName.exe"
varLink = "http://YourUrl/" & varFileName
varHTTP.Open "GET", varLink, False
varHTTP.Send

With varBinaryString
.Type = 1 'my type has been set to binary
.Open
.Write varHTTP.responseBody
.SaveToFile ".\" & varFileName, 2 'if exist, overwrite
End With
varBinaryString.close

msgbox "Done!"

WScript.Quit(0)

 

Script 2

On error resume next
Dim PageStart, PagesToDownload, notebookpage
Set objFSO = CreateObject( "Scripting.FileSystemObject" )

'STARTING PAGE TO DOWNLOAD
PageStart=1

'HOW MANY PAGES TO DOWNLOAD
PagesToDownload = 40

Do while PageStart < PagesToDownload
notebookpage = "<a href="http://eddiejackson.net/web_images/notebook_"><span style="text-decoration: underline;"><span style="color: #0000ff; font-size: medium;"><span style="color: #0000ff; font-size: medium;">http://eddiejackson.net/web_images/notebook_</span></span></span></a><span style="font-size: medium;">" & PageStart & ".jpg"
</span>If objFSO.FileExists (".\notebook_" & PageStart & ".jpg") then
'msgbox "FILE EXIST: notebook_" & PageStart & ".jpg"
PageStart=PageStart+1
Else
'msgbox "FILE DOES NOT EXIST: notebook_" & PageStart & ".jpg"
HTTPDownload notebookpage, "."
PageStart=PageStart+1
end if

loop

WScript.Quit(0)

Sub HTTPDownload( myURL, myPath )
'DEFINE MY VARIABLES
Dim i, objFile, objFSO, objHTTP, strFile, strMsg
Const ForReading = 1, ForWriting = 2, ForAppending = 8

'CREATE OBJECT
Set objFSO = CreateObject( "Scripting.FileSystemObject" )

' Check if the specified target file or folder exists,
' and build the fully qualified path of the target file
If objFSO.FolderExists( myPath ) Then
On error resume next
strFile = objFSO.BuildPath( myPath, Mid( myURL, InStrRev( myURL, "/" ) + 1 ) )
ElseIf objFSO.FolderExists( Left( myPath, InStrRev( myPath, "\" ) - 1 ) ) Then
strFile = myPath
Else
'WScript.Echo "ERROR: Target folder not found."
Exit Sub
End If

' Create or open the target file
Set objFile = objFSO.OpenTextFile( strFile, ForWriting, True )

' Create an HTTP object
Set objHTTP = CreateObject( "WinHttp.WinHttpRequest.5.1" )

' Download the specified URL
objHTTP.Open "GET", myURL, False
objHTTP.Send

' Write the downloaded byte stream to the target file
For i = 1 To LenB( objHTTP.ResponseBody )
On error resume next
objFile.Write Chr( AscB( MidB( objHTTP.ResponseBody, i, 1 ) ) )
Next

' Close the target file
objFile.Close( )

End Sub

Custom Reg Keys

These allow you to set settings through the registry, which can be added to your scripts to automate the changes.

Registry settings for all those annoying HKEY_CURRENT_USER user interface settings that are likely to drive you nuts when running WinXP:

Windows Registry Editor Version 5.00

; Usual disclaimers apply – don’t edit the registry unless you know what you are doing and
; BACKUP THE REGISTRY FIRST
; If you edit this file ensure all comment lines are prefixed with
; so that REGEDIT will ignore them

 

; ;- – – Section1 – – – – MS Explorer  – – – – – – – – – – – – – – – – – – – – – – – – – –
; [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer]

; Disable the animated Click Start to begin
“NoStartBanner”=hex:01,00,00,00

; Don’t constantly shuffle around the start menu items
“Intellimenus”=dword:00000000

;  Use the classic Start Menu
“NoSimpleStartMenu”=dword:00000001

; Dont tie new shortcuts to a specific PC
“LinkResolveIgnoreLinkInfo”=dword:00000001

; Don’t hide all the local Drives
“NoDrives”=dword:00000000

; Don’t display a welcome screen
“NoWelcomeScreen”=dword:00000001

; Don’t automatically create shortcuts within My Network Places
“NoRecentDocsNetHood”=dword:00000001

; Don’t run the Desktop Cleanup Wizard
“NoDesktopCleanupWizard”=dword:00000001

; Don’t create a Shared Documents folder for My Computer
“NoSharedDocuments”=dword:00000001

; Don’t hide the log-off option from the start menu
“ForceStartMenuLogOff”=dword:00000001

; Don’t clutter start menu with My Network Places
“NoStartMenuNetworkPlaces”=dword:00000001

; Don’t add a My Documents shortcut to the start menu
“NoSMMyDocs”=dword:00000001

; Don’t add a Favorites shortcut to the start menu
“NoFavoritesMenu”=dword:00000001

; Don’t add a My Pictures shortcut to the start menu
“NoSMMyPictures”=dword:00000001

; Don’t add a My Music shortcut to the start menu
“NoStartMenuMyMusic”=dword:00000001

; Don’t hide any of the following settings in the explorer GUI
“NoActiveDesktopChanges”=hex:00,00,00,00
“NoActiveDesktop”=dword:00000000
“NoSaveSettings”=dword:00000000
“ClassicShell”=dword:00000000
“NoThemesTab”=dword:00000000

; Disable active desktop
“NoActiveDesktop”=hex:01,00,00,00

; Don’t ignore the flag above, really disable active desktop
“ForceActiveDesktopOn”=dword:00000000

; Enable Windows Update
; “NoWindowsUpdate”=dword:00000000
; OR
; Disable Windows Update
; “NoWindowsUpdate”=dword:00000001

; ; – – – Section2 – – – –  Explorer\Advanced  – – – – – – – – – – – – – – – – – –
; [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced]

; Show hidden files and folders
; “Hidden”=dword:00000001
; or Don’t show hidden files and folders:
; “Hidden”=dword:00000002

; Don’t Hide file extensions
“HideFileExt”=dword:00000000

; Don’t change the upper/lower case of filenames
“DontPrettyPath”=dword:00000001

;  Hide the Start Button BalloonTip (Click here to begin)
“StartButtonBalloonTip”=dword:00000000

; Don’t randomly open copies of windows explorer when I login
“PersistBrowsers”=dword:00000000

; ; – – – Section 3 – – – – Policy settings  – – – – – – – – – – – – – – – – – – – –
;[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System]

; Don’t hide any of the following options (normally under Control Panel, Desktop)
“NoDispAppearancePage”=dword:00000000
“NoColorChoice”=dword:00000000
“NoSizeChoice”=dword:00000000
“NoDispBackgroundPage”=dword:00000000
“NoDispScrSavPage”=dword:00000000
“NoDispCPL”=dword:00000000
“NoVisualStyleChoice”=dword:00000000
“NoDispSettingsPage”=dword:00000000
“NoDispScrSavPage”=dword:00000000
“NoVisualStyleChoice”=dword:00000000
“NoSizeChoice”=dword:00000000
“SetVisualStyle”=-

; ; – – – Section 4 – – – – Policy – Add-Remove Programs restrictions   – – – – – –
; ; These keys make sure you can uninstall anything
; HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Uninstall]
“NoAddRemovePrograms”=dword:00000000
“NoRemovePage”=dword:00000000
“NoAddPage”=dword:00000000
“NoWindowsSetupPage”=dword:00000000
“NoAddFromCDorFloppy”=dword:00000000
“NoAddFromInternet”=dword:00000000
“NoAddFromNetwork”=dword:00000000
“NoServices”=dword:00000000
“NoSupportInfo”=dword:00000000

; ; – – – Section 5 – – – –  Control Panel  – – – – – – – – – – – – – – – – – – –
; ; Dont hide any cpanel applets see Q207750
[HKEY_CURRENT_USER\Control Panel\don’t load]
“appwiz.cpl”=-

; Start menu speed
[HKEY_CURRENT_USER\Control Panel\Desktop]
; (the default of 400 is a bit slow)
“MenuShowDelay”=”100”

; ; – – – Section 6 – – – –  Console  – – – – – – – – – – – – – – – – – – – – – –
; [HKEY_CURRENT_USER\Console]
; Allow copy and paste from the command line.
“QuickEdit”=dword:00000001

; ; – – – Section 7 – – – –  Tip Of the Day  – – – – – – – – – – – – – – – – – – –
; ;  Turn off the ‘Tip Of the Day’
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\tips]
“Show”=dword:00000000

email me

Check and Log into Form

This allows you to automatically log into a website if it uses a form/pop-up username and password.

Dim IE
Dim Helem
on error resume next
set WshShell = WScript.CreateObject("WScript.Shell")
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = 1
IE.navigate "THE_WEB_ADDRESS"
WScript.Sleep 3000
'WshShell.AppActivate "Windows Security"
'WScript.Sleep 1000
'WshShell.SendKeys "{ESC}"
Set Helem = IE.document.getElementByID("formUsername")
Helem.Value = "YOURUSERNMAE" ' change this to yours
Set Helem = IE.document.getElementByID("formPassword")
Helem.Value = "YOURPASSWORD" ' change this to yours
Set Helem = IE.document.Forms(0)
Helem.Submit

Do While (IE.Busy)
WScript.Sleep 10
Loop

Dim someElement
Set someElement = IE.document.getElementByID("someElement")
If Len(someElement.innerText) > 0 Then
MsgBox "logged in"
'WScript.Sleep 2000
'WshShell.SendKeys "{F5}"
End If

 

Delete all Temps in all Profiles

This VBScript allows you to clear all temps in all user profiles.

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder("C:\Users")
Set colSubfolders = objFolder.Subfolders

On Error Resume Next

For Each objSubfolder in colSubfolders
'    WScript.Echo "for loop 1"
WScript.Echo objSubfolder.Name
Set TempFolder = objFSO.getFolder("c:\Users\" & objSubfolder.Name & "\AppData\Local\Temp")
For Each objFile In TempFolder.Files
objFile.Delete
'WScript.Echo objFile.Path
Next
Next

For Each objSubfolder In colSubfolders
Set TempFolder2 = objFSO.getFolder("c:\Users\" & objSubfolder.Name & "\AppData\Local\Temp")
For Each objfolder In tempfolder2.SubFolders
objfso.DeleteFolder objFolder
Next
Next