Δ
AutoIT Script: Import LANDesk Certificate
When dealing with LANDesk, you will eventually have to address how your offsite/home-users will import the LANDesk certificate. Well, here's the script that will allow them just to click a file and the certificate will automatically be imported. Pretty nice if you don't want to send a page of instructions to your home end-users. |
Here are our specs:
|
Create Script to automatically import certificate Make sure the end-user cannot access kb/mouse
|
**********************************************************************
Language: AutoIT
Script: ImportCert.exe
Purpose: To import LANDesk Certificate
Creation Date: 12/02/09
Last Modified:
Author: Eddie S. Jackson
E-Mail: MrNetTek@gmail.com
***********************************************************************
;This disables input from mouse and keyboard BlockInput(1) ;This section launches BrokerConfig.exe and retrieves the gateway certificate Run ("c:\program files\landesk\ldclient\brokerconfig.exe") WinWaitActive("LANDesk Management Gateway") ControlSend ("LANDesk Management Gateway", "", 1008, "username") ControlSend ("LANDesk Management Gateway", "", 1009, "password") ControlClick ("LANDesk Management Gateway", "Send", 1002) ;The Sleep command is necessary because it takes a little time to retrieve the certificate. This value is in miliseconds, and can be adjusted based on how ;quickly your gateway responds with the certificate. The default value here is 40 seconds. Sleep (40000) ControlClick("LANDesk Management Gateway", "", "[ID:2]") WinClose("LANDesk Management Gateway") ;This enables input from mouse and keyboard BlockInput(0)
|
Δ
Compile File For Download And Install
How to create a quick download and installation file for a screensaver (or other file) for your website. Demo Link.
This is basically how to create a file installer right from your web page; it makes easier for your users to install and run a program. They will click the link, download, run the installer, and viola the program gets installed; quick and easy. |
Step 1 - Create your command file
start "" rundll32.exe desk.cpl,InstallScreenSaver stars.scr exit
|
Step 2 - Zip your command file and screensaver into a single zip file.
Step 3 - Use self extracter zip ChilkatZipSE.exe to create self-extracting EXE.
Step 4 - Zip your self-extracting EXE into a zip file.
Step 5 - Upload your zipped EXE file to the website.
Step 6 - Create a link on your web page to zip file. It will look something like this: http://YourWebSite.com/files/installme.zip
Δ
Querying File Versions In A Batch Script
How would you query the version of a file/driver from within a batch file?
Proof of concept: |
To query driver/file version and output to screen
|
version.vbs
Set objFSO = CreateObject("Scripting.FileSystemObject") Wscript.Echo objFSO.GetFileVersion(wscript.arguments(0))
|
getversion.cmd
cls & cscript c:\version.vbs C:\WINDOWS\system32\drivers\NETw5x32.sys //Nologo
|
Used to Uninstall previous version of Adobe Reader and Adobe Pro 8, and install the latest Adobe Reader 9 and Pro 9 to your network computers.
Here are our specs:
|
Uninstall previous versions of Adobe Reader Uninstall Adobe Professional 8 Install Adobe Reader 9 Install Adobe Professional 9 Must cycle through a computer list
|
:: ******************************************************************************** :: Script Language: Shell :: Script Name: _RUNME.cmd :: Purpose: To install Adobe Reader 9 via list of computers with email notification :: Creation Date: 12/17/09 :: Last Modified: :: Directions: double-click the _RUNME.cmd :: Author: Eddie Jackson :: Email: MrNetTek@gmail.com :: ********************************************************************************
color 6a @title=Installing Adobe Reader 9.. ::ipconfig /flushdns ::nbtstat -RR ::netsh interface ip delete arpcache
@ECHO OFF @ECHO off >> C:\AdobeReader9\Offline.txt @ECHO off >> C:\AdobeReader9\Online.txt setLocal EnableDelayedExpansion
for /f "tokens=* delims= " %%a in (C:\AdobeReader9\computers.txt) do ( ping %%a | find "Reply" > nul
if errorlevel 1 (echo %date% %time%, %%a, OFFLINE >> C:\AdobeReader9\Offline.txt & echo %%a OFFLINE ) else ( taskkill /s %%a /f /im psexesvc.exe xcopy C:\AdobeReader9\AdobeCommand.cmd \\%%a\c$\windows\system32\ /y xcopy C:\AdobeReader9\Source\AdbeRdr920_en_US.exe \\%%a\c$\windows\temp\ /y psexec \\%%a AdobeCommand.cmd for /f "tokens=2 delims=\" %%e in ('wmic /node:"%%a" ComputerSystem Get UserName') do set UserName=%%e set UserName=%UserName: =% rem taskkill /f /im psexec.exe If EXIST \\%%a\c$\"Program Files"\Adobe\"Reader 9.0"\ echo %date% %time%, %%a, %UserName%, ONLINE >> C:\AdobeReader9\Online.txt If NOT EXIST \\%%a\c$\"Program Files"\Adobe\"Reader 9.0"\ echo %date% %time%, %%a, ONLINE >> C:\AdobeReader9\OFFLINE.txt ) ) wscript C:\AdobeReader9\email.vbs ipconfig /flushdns nbtstat -RR netsh interface ip delete arpcache exit
::::ADOBESCRIPT.CMD :: ********************************************************************** :: Script: ADOBESCRIPT.CMD :: Purpose: To uninstall all previous versions of Adobe Reader and uninstall Adobe Pro 8 :: To install Adobe Reader 9.1 :: Creation Date: 12/08/09 :: Last Modified: :: Author: Eddie S. Jackson :: E-Mail: MrNetTek@gmail.com :: ********************************************************************** :: ::@ECHO off ::Title = Adobe Installer by Tech Ops :: :: Version 6.01: :: MSIEXEC /UNINSTALL {AC76BA86-7AD7-1033-7B44-A00000000001} REBOOT=SUPRESS /QB- :: :: Version 7.09: :: MSIEXEC /UNINSTALL {AC76BA86-7AD7-1033-7B44-A70900000002} REBOOT=SUPRESS /QB- :: :: Version 8.0: :: MSIEXEC /UNINSTALL {AC76BA86-7AD7-1033-7B44-A80000000002} REBOOT=SUPRESS /QB- :: :: Version 8 Professional: :: MsiExec.exe /x{AC76BA86-1033-0000-7760-000000000003} REBOOT=SUPRESS /qn :: :: Install Adobe Reader 9 :: start /wait \\"servername\Adobe Acrobat Reader 9.1"\AdbeRdr910_en_US_Std.exe /sAll /rs :: /l /msi"/qb-! /norestart ALLUSERS=1 EULA_ACCEPT=YES SUPPRESS_APP_LAUNCH=YES" :: start /wait c:\windows\temp\AdbeRdr920_en_US.exe /sAll /rs /l /msi"/qb-! /norestart ALLUSERS=1 EULA_ACCEPT=YES SUPPRESS_APP_LAUNCH=YES"
::Install Adobe Pro 9 ::msiexec.exe /i \\servername\AdobePro9\source\AcroPro.msi /qn TRANSFORMS=\\servername\AdobePro9\source\AcroPro.mst
::::email.vbs ::On Error Resume Next ::Dim Name(1) ::Name(0)="MrNetTek@gmail.com" :: ::'This sets the attachment to be sent ::Dim File(3) ::File(0) = "C:\AdobeReader9\Online.txt" ::File(1) = "C:\AdobeReader9\Offline.txt" ::File(2) = "C:\AdobeReader9\computers.txt" :: ::MSG = "Adobe Reader 9 Installs" ::SUBJ = "Adobe Reader 9 Installs" :: ::Set Outlook = CreateObject("Outlook.Application") ::Set MAPI = Outlook.GetNameSpace("MAPI") ::Set NewMail = OUtlook.CreateItem(0) ::NewMail.Subject = SUBJ ::NewMail.Body = MSG ::'NewMail.Recipients.Add RCP :: ::For X= 0 to (UBound(Name)-1) :: NewMail.Recipients.Add Name(X) ::Next :: ::For X= 0 to (UBound(File)-1) :: NewMail.Attachments.Add(file(X)) ::Next :: ::NewMail.Send
|
Δ Email Script
Used to email reports and other data through an email account. You can tag this on to the end of any of your scripts no matter what scripting languange you're using, and you will receive an email when your script is complete. You will have to have outlook running on that machine, preferably using a service account. Another way to have done this is using smtp, however, if smtp relaying is not enabled, your script will not work. This is a great alternative.. |
Here are our specs: |
Create a script to email data to an email account
|
'=============================================== 'L A N G U A G E
'VBScript
' 'S C R I P T N A M E 'email.VBS ' 'P U R P O S E 'To
email you information after a script is done
' 'U S A G E 'Edit email.vbs with the recepients, message, and subject
line 'Then just call from any script: wscript email.vbs
' 'A U T H O R 'Eddie S. Jackson ' 'D A T E C R E A T E DD
'12/7/09 '===============================================
On
Error Resume Next 'RCP == MrNetTek@Gmail.com Dim Name(2)
Name(0)==MrNetTek@Gmail.com Name(1)==MrNetTek2000@Yahoo.com
'This sets the
attachment to be sent Dim File(1) File(0) = "C:\workstations.txt"
MSG = "Workstaton Results" SUBJ = "Workstaton
Results"
Set Outlook = CreateObject("Outlook.Application")
Set MAPI = Outlook.GetNameSpace("MAPI") Set NewMail = OUtlook.CreateItem(0)
NewMail.Subject = SUBJ NewMail.Body = MSG 'NewMail.Recipients.Add RCP
For X= 0 to (UBound(Name)-1)
NewMail.Recipients.Add Name(X) Nextt
For X= 0 to (UBound(File)-1)
NewMail.Attachments.Add(file(X)) Next
NewMail.Send
|
Δ
Copy & Compress Logs To Timestamped FolderCopy & Compress Logs To Timestamped Folder
To The Network
This was created with the need to automate the uploading of log files to the network. The total, daily storage space required for the logs were upward of 250MB. So to conserve hard drive space, we need these logs automatically compressed, as well as a new folder must be created each day being named the timestamp of the creation date and time.
Here are our specs:
|
Apply verbose registry key remotely Create a timestamped named folder Copy verbose log from workstation Compress log to conserve storage Must cycle through workstation list
|
:: ******************************************************************************** :: Script Language: Shell :: Script Name: Verbose.cmd :: Purpose: Copies logs from workstations to a timestamped folder, compresses logs, :: runs every 24 hours with email notification :: Creation Date: 12/11/09 :: Last Modified: :: Directions: double-click the verbose.cmd :: Author: Eddie Jackson :: Email: MrNetTek@Gmail.com :: ********************************************************************************
@ECHO OFF title=Verbose Logging... &color 4e
@ECHO OFF :MAIN ::datestamp for /f "tokens=2-4 skip=1 delims=(-./)" %%i in ('echo.^|date') do ( for /f "tokens=1-4 delims=-./ " %%m in ('date /t') do ( (set dow=%%m)&(set %%i=%%n)&(set %%j=%%o)&(set yy=%%p) ) ) For /F "tokens=1,2 delims=:, " %%i in ('TIME /T') Do (Set HHMM=%%i%%j)
md \\server\logs\%mm%-%dd%-%yy%_%HHMM%
:BEGINLOOP setLocal EnableDelayedExpansion
for /f "tokens=* delims= " %%a in (C:\VerboseLogging\computers.txt) do ( ping %%a | find "Reply" > nul
if errorlevel 1 (echo %date% %time%, %%a, OFFLINE >> C:\VerboseLogging\Offline.txt & echo %%a OFFLINE ) else ( copy c:\VerboseLogging\verbose.reg \\%%a\c$\windows\system32 psexec \\%%a regedit /s verbose.reg copy /y \\%%a\c$\windows\debug\UserMode\userenv.log \\server\logs\%mm%-%dd%-%yy%_%HHMM%\%%a.log pkzipc -add \\server\logs\%mm%-%dd%-%yy%_%HHMM%\%%a.zip \\server\logs\%mm%-%dd%-%yy%_%HHMM%\%%a.log del \\server\logs\%mm%-%dd%-%yy%_%HHMM%\%%a.log /q echo %date% %time%, %%a, ONLINE >> C:\VerboseLogging\Online.txt & echo %%a Online ) )
:END
cls wscript C:\VerboseLogging\email.vbs Echo Sleeping for 24 hours
sleep 86400 goto MAIN
|
Δ
BGInfo Install To Your Network Computers
BGInfoBGInfo is a great little utility by SysInternals that shows preset and customized info in a corner on your computer desktop. Items like computer name, IP address, memory and computer model just to name a few. There are several ways to deploy the files to your network computers, domain group policy being the best solution if it is technically viable. In this case, we were thinking about GP, however, needed a secondary method that would allow for testing, automated single installations, and logging. The files we will be working with are bginfo.lnk, bginfo.exe and bginfo.bgi.
This is the BGInfo interface, configure the .BGI file.
Configure BGInfo.BGI for primary display only; otherwise overlays can happen.
Add your own items like WMI queries and reg key queries; tailoring for your desktop reqs.
|
Here are our specs:
|
To copy BGInfo files to your network computers Set everyone permissions on the bginfo folder Create online and offline logs Send email notification when done
|
:: ************************************************************************** :: Script Language: Shell :: Script Name: BGinfo.cmd :: Purpose: To install bginfo via list of computers with email notification :: Creation Date: 12/10/09 :: Last Modified: :: Directions: double-click the BGinfo.cmd :: Author: Eddie Jackson :: Email: MrNetTek@gmail.com :: **************************************************************************
color 3a @title=Installing BGInfo... ipconfig /flushdns nbtstat -RR netsh interface ip delete arpcache
@ECHO OFF @ECHO off >> C:\BGInfo\Offline.txt @ECHO off >> C:\BGInfo\Online.txt setLocal EnableDelayedExpansion
for /f "tokens=* delims= " %%a in (C:\BGInfo\computers.txt) do ( ping %%a | find "Reply" > nul
if errorlevel 1 (echo %date% %time%, %%a, OFFLINE >> C:\BGInfo\Offline.txt & echo %%a OFFLINE ) else ( taskkill /s %%a /f /im psexesvc.exe md \\%%a\c$\"Program Files"\bginfo\ xcopy C:\BGInfo\ChangePermBGInfo.cmd \\%%a\c$\windows\system32\ /y xcopy C:\BGInfo\BGInfo\bginfo.bgi \\%%a\c$\"Program Files"\bginfo\ /y xcopy C:\BGInfo\BGInfo\bginfo.exe \\%%a\c$\"Program Files"\bginfo\ /y xcopy C:\BGInfo\BGInfo\bginfo.lnk \\%%a\c$\"Program Files"\bginfo\ /y xcopy C:\BGInfo\BGInfo\bginfo.lnk \\%%a\c$\"Documents and Settings"\"All Users"\"Start Menu"\Programs\Startup\ /y psexec \\%%a ChangePermBGInfo.cmd If EXIST \\%%a\c$\"Program Files"\bginfo\ echo %date% %time%, %%a, ONLINE >> C:\BGInfo\Online.txt If NOT EXIST \\%%a\c$\"Program Files"\bginfo\ echo %date% %time%, %%a, ONLINE >> C:\BGInfo\OFFLINE.txt ) ) wscript C:\BGInfo\_email.vbs ::ipconfig /flushdns ::nbtstat -RR ::netsh interface ip delete arpcache exit
::::ChangePermBGInfo.cmd ::echo y | cacls "C:\Program Files\bginfo" /E /G Everyone:F
::::_email.vbs ::On Error Resume Next ::Dim Name(1) ::Name(0)="MrNetTek@gmail.com"
:: ::'This sets the attachment to be sent ::Dim File(3) ::File(0) = "C:\BGInfo\Online.txt" ::File(1) = "C:\BGInfo\Offline.txt" ::File(2) = "C:\BGInfo\computers.txt" :: ::MSG = "BGInfo Installs" ::SUBJ = "BGInfo Installs" :: ::Set Outlook = CreateObject("Outlook.Application") ::Set MAPI = Outlook.GetNameSpace("MAPI") ::Set NewMail = OUtlook.CreateItem(0) ::NewMail.Subject = SUBJ ::NewMail.Body = MSG :: ::For X= 0 to (UBound(Name)-1) :: NewMail.Recipients.Add Name(X) ::Next :: ::For X= 0 to (UBound(File)-1) :: NewMail.Attachments.Add(file(X)) ::Next :: ::NewMail.Send
|
Δ
Webmail String
The Outlook Web Access address looks something like this: https://webmail.YourServer.com/OWA/The Outlook Web Access address looks something like this: https://webmail.YourServer.com/OWA/
I am sure everyone is familiar with that address. What you may not know is that there can be some string scripting done right in the URL..
It would look something like this::
https://webmail.YourServer.edu/OWA/?ae=Item&a=New&t=IPM.Note&to=YourFriend@HisAccount.com&subject=LookSubjectGoesHeree
What that allows you to do is create a new message, auto-populate the recipient's address and the subject line..
Why, you ask, would I want to auto-populate fields? Let's say you created several scripts made available to you only through Webmail access. But there is no way of remembering how many times you are accessing each task. So, what you want to do at the end of each process is create a new webmail message, fill in the recipient as you and with the process name filled in on the subject line. This is kind of a personal tracking system you have put into place so you will remember just how many times each task was executed through the webmail interface..
Now, with that said, scripted with a little code, we can create a new webmail message, auto-populate the fields, add environmental variables, and any other automation data that we would like generated at the end of the process::
@Echo off clss Title=Launching Secure OWA by Eddie Jacksonn taskkill /fi "WINDOWTITLE eq https://webmail.YourServer/OWA/redir.aspx*"" @ping -n 1 127.0.0.1>null start "" https://webmail.YourServer/OWA/?ae=Item&a=New&t=IPM.Note&to=MrNetTek@gmail.com&subject=LookSubjectGoesHere %USERNAME% %COMPUTERNAME%% @ping -n 2 127.0.0.1>null
:MONITOR TASKLIST /v /FI
"WINDOWTITLE eq LookSubjectGoesHere*" | find /i "LookSubjectGoesHere" && goto
NEXT goto END
:NEXT echo set WshShell =
WScript.CreateObject("WScript.Shell")> %temp%\sendinfo.vbs echo
WshShell.AppActivate "LookSubjectGoesHere %USERNAME%*">> %temp%\sendinfo.vbs echo WshShell.SendKeys "{TAB}">> %temp%\sendinfo.vbs
echo WshShell.AppActivate "LookSubjectGoesHere %USERNAME%*">>
%temp%\sendinfo.vbs echo WshShell.SendKeys "Install Your App Name Here">> %temp%\sendinfo.vbs echo WshShell.SendKeys "{ENTER}">> %temp%\sendinfo.vbs echo WshShell.SendKeys "Computer Name: %COMPUTERNAME%">> %temp%\sendinfo.vbs echo WshShell.SendKeys "{ENTER}">> %temp%\sendinfo.vbs
echo WshShell.SendKeys "User Name: %USERNAME%">> %temp%\sendinfo.vbs echo
WshShell.SendKeys "{ENTER}">> %temp%\sendinfo.vbs echo WshShell.SendKeys
"{ENTER}">> %temp%\sendinfo.vbs echo WshShell.SendKeys "Other automation
data can be entered here.">> %temp%\sendinfo.vbs ::echo WshShell.SendKeys
"^{enter}" >> %temp%\sendinfo.vbs WScript.exe %temp%\sendinfo.vbs
:END EXIT
|
This is the output of the script once your task has completed:
|
Δ Webmail One-Touch Access
A really interesting concept of where rather than carrying your USB/Flash drive everywhere you go with all your working quick fixes and basic software apps, you could easily access all your most practical software via a webmail page. How it works is you access your webmail from any end-users workstation, open the panel, and click the UNC reference pointer that is basically compiled batch/vbscript or other scripted application that launches the setup or quick fix under escalated security credentials. Pretty nice especially if your company doesn't allow USB drives. This also allows you to change security context to allow you to access network resources from an end-users desk who doesn't have access. |
Proof of concept: |
Create one touch access panel for a webmail page
|
One-Touch Accesss
|
|
..About
..I'm
a Computer ..Systems Engineer
..Living and loving life ........................................
..Author
....
|