Return Only Numerics from String

email me

This is how to take a string of data that contains letters and numbers, and only return the number data.

I was using this to return computer model numbers…

on error resume next

Dim ObjRegExp, numStr, varStr

varStr="Elitebook 840 G1"

numStr=""
Set ObjRegExp = New RegExp
ObjRegExp.Pattern = "[W]+|[a-zA-Z]+"
ObjRegExp.IgnoreCase = True
ObjRegExp.Global = True
numStr = ObjRegExp.Replace(varStr,"")
Msgbox numStr

 

 

Update

I noticed that some models, such as 840 G1, would return 840 1. To remove the space, I added

Replace(strPostcode," ","",1,-1)

My script

Dim objWMI : Set objWMI = GetObject("winmgmts:")
Dim colSettingsComp : Set colSettings = objWMI.ExecQuery("Select * from Win32_ComputerSystem")

For Each objComputer in colSettings
LaptopModel = Trim(objComputer.Model)
Next

'RETURN ONLY NUMERIC PORTION OF COMPUTER MODEL
numStr=""
Set objRegExp = New RegExp
objRegExp.Pattern ="[W]+|[a-zA-Z]+"
objRegExp.IgnoreCase = True
objRegExp.Global = True
numStr = objRegExp.Replace(LaptopModel,"")
numStr = Replace(numStr," ","",1,-1)'REMOVES SPACES

msgbox numStr

Context Sensitive Keyboard Control: AutoHotkey

email me

Using AutoHotkey, you can block specific keys on the keyboard:

SetTitleMatchMode, 2
SendMode Input 
#NoEnv

Keys := ["F1","F2","F3","F4","F5","F6","F7","F8","F9","F10","F11","F12","Backspace","LButton","RButton","Escape","Tab","Delete","Numpad0","Numpad1","Numpad2","Numpad3","Numpad4","Numpad5","Numpad6","Numpad7","Numpad8","Numpad9","NumpadDot","NumpadDiv","NumpadMult","NumpadAdd","NumpadSub","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","1","2","3","4","5","6","7","8","9","0",";","'",",",".","/","\","[","]","-","=","{","}","+","_","!","@","#","$","%","^","&","*","(",")","<",">","?","``","~","|"]

for k, v in Keys
  In(v, "a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z") ? (HotKey("+" v, "BlockKey"),  HotKey("^" v, "BlockKey"), HotKey(v, "BlockKey")) : (HotKey(v, "BlockKey"), HotKey("^" v, "BlockKey")) ?  (HotKey("+" v, "BlockKey"),  HotKey("!" v, "BlockKey"), HotKey(v, "BlockKey")) : (HotKey(v, "BlockKey"), HotKey("!" v, "BlockKey"))
return

#If (WinActive("ahk_class Notepad"))

BlockKey:
Key := InStr(A_ThisHotkey, "+", "false", "1") || InStr(A_ThisHotkey, "^", "false", "1") || InStr(A_ThisHotkey, "!", "false", "1")  ? (SubStr(A_ThisHotkey, "0", "1"), Mod := SubStr(A_ThisHotkey, "1", "1"))  : (A_ThisHotkey, Mod := "") ; || InStr(A_ThisHotkey, "!", "false", "1") 
If (WinActive("ahk_class Notepad") && Mod . Key <> "^c")
   return
else
   Send, %Mod%{%Key%}
return

In(var, Matchlist)
{
   if var in %Matchlist%
      return True
}

Hotkey(ByRef KeyName, ByRef Label) 
{
   HotKey, %KeyName%, %Label%
}

 

 

Notes

Ahk2Exe can be used in the following ways:

 

  1. GUI Interface: Run the “Convert .ahk to .exe” item in the Start Menu.
  2. Right-click: Within an open Explorer window, you can right-click any .ahk file and select “Compile Script” (only available if the script compiler option was chosen when AutoHotkey was installed).

Download AutoHotkey

Blocking Keyboard Input: AutoHotKey

email me

#NoTrayIcon 

SendMode Input

Keys := ["Alt","Space","Tab","Delete","Numpad0","Numpad1","Numpad2","Numpad3","Numpad4","Numpad5","Numpad6","Numpad7","Numpad8","Numpad9","NumpadDot","NumpadDiv","NumpadMult","NumpadAdd","NumpadSub","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","1","2","3","4","5","6","7","8","9","0",";","'",",",".","/","\","[","]","-","=","{","}","+","_","!","@","#","$","%","^","&","*","(",")","<",">","?","``","~","|"]

for k, v in Keys
   In(v, "a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z") ? (HotKey("+" v, "BlockKey"), HotKey(v, "BlockKey")) : HotKey(v, "BlockKey")
return

BlockKey:
Key := InStr(A_ThisHotkey, "+", "false", "1") ? (SubStr(A_ThisHotkey, "0", "1"), Mod := SubStr(A_ThisHotkey, "1", "1"))  : (A_ThisHotkey, Mod := "")

   return

In(var, Matchlist)
{
   if var in %Matchlist%
      return True
}

Hotkey(ByRef KeyName, ByRef Label) 
{
   HotKey, %KeyName%, %Label%
}

 

Notes

Ahk2Exe can be used in the following ways:

  1. GUI Interface: Run the “Convert .ahk to .exe” item in the Start Menu.
  2. Right-click: Within an open Explorer window, you can right-click any .ahk file and select “Compile Script” (only available if the script compiler option was chosen when AutoHotkey was installed).

Download AutoHotKey

Controlling Blocked Input: AutoIt

email me

Just set your timer to however many seconds you want to disable the mouse and keyboard…and the input will be blocked. You could also comment out the BlockInput(0), and the Input will not return.

BlockInput(1)
$timer = 10
For $i = 1 To $timer Step +1
Sleep(1000)
$Coords = MouseGetPos()
ConsoleWrite($timer  $i &  seconds Remaining & @CRLF)
TrayTip(Keyboard & Mouse Frozen, $timer  $i &  seconds Remaining, 1)
ToolTip($timer  $i &  seconds Remaining, $Coords[0], $Coords[1], Keyboard & Mouse Frozen)
Next
BlockInput(0)

Updated iTunes 12.1.2.27 Sequence File

email me

I used this, minus some company branding, to deploy iTunes to the enterprise. Note, this can be converted to VBScript or PowerShell.

@ECHO ON
TITLE iTunes Installation
color 0a
Setlocal EnableDelayedExpansion
Set CurDir=%CD%

CLS

rem if exist “C:\Program Files (x86)\LANDesk\LDClient\sdmcache\apps\Apple\iTunes\12.1.2.27\” (
rem SET LDPath=C:\Program Files (x86)\LANDesk\LDClient\sdmcache\apps\Apple\iTunes\12.1.2.27
rem )
rem if not exist “C:\Program Files (x86)\LANDesk\LDClient\sdmcache\apps\Apple\iTunes\12.1.2.27\” (
rem SET LDPath=%CD%
rem )

rem SET LDPath=C:\Program Files (x86)\LANDesk\LDClient\sdmcache\apps\Apple\iTunes\12.1.2.27
SET UName=LANDesk

ECHO Installing iTunes…
%windir%\system32\EVENTCREATE.exe /T INFORMATION /L Application /ID 777 /d “iTunes 12.1.2.27 package installation STARTED by %UName%”

rem kill running tasks
taskkill /f /im itunes.exe
taskkill /f /im ipodservice.exe
taskkill /f /im AppleMobileDeviceService.exe

rem uninstall
c:\windows\system32\msiexec.exe /x {B8BA155B-1E75-405F-9CB4-8A99615D09DC} /qn /norestart
c:\windows\system32\msiexec.exe /x {6E3610B2-430D-4EB0-81E3-2B57E8B9DE8D} /qn /norestart

c:\windows\system32\msiexec.exe /x {787136D2-F0F8-4625-AA3F-72D7795AC842} /qn /norestart
c:\windows\system32\msiexec.exe /x {B8BA155B-1E75-405F-9CB4-8A99615D09DC} /qn /norestart
c:\windows\system32\msiexec.exe /x {33E28B58-7BA0-47B7-AA01-9225ABA2B8A9} /qn /norestart
reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{B8BA155B-1E75-405F-9CB4-8A99615D09DC} /f /reg:64
reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{B8BA155B-1E75-405F-9CB4-8A99615D09DC} /f
ping -n 30 127.0.0.1>nul

c:\windows\system32\msiexec.exe /i “%CurDir%\AppleApplicationSupport.msi” /qn /norestart
c:\windows\system32\msiexec.exe /i “%CurDir%\AppleApplicationSupport64.msi” /qn /norestart
c:\windows\system32\msiexec.exe /i “%CurDir%\AppleMobileDeviceSupport64.msi” /qn /norestart
c:\windows\system32\msiexec.exe /i “%CurDir%\Bonjour64.msi” /qn /norestart
c:\windows\system32\msiexec.exe /i “%CurDir%\AppleSoftwareUpdate.msi” /qn /norestart
c:\windows\system32\msiexec.exe /i “%CurDir%\iTunes6464.msi” /qn /norestart IAcceptLicense=Yes ALLUSERS=1 DESKTOP_SHORTCUTS=1 INSTALL_ASUW=0 NO_ASUW=1
“%CurDir%\copytoallprofiles_7.vbs”
rem STANDALONE=1 AMDS_IS_INSTALLED=1 APPLEAPPLICATIONSUPPORT_IS_INSTALLED=1 DESKTOP_SHORTCUTS=1 FORCE_SUB_INSTALLS=0 INSTALL_ASUW=0 REENABLEAUTORUN=0 OUTLOOK_LOAD_BEHAVIOR=0 MEDIA_DEFAULTS=0 NO_ASUW=1 QUICKTIME_IS_INSTALLED=1 IAcceptLicense=Yes LaunchiTunesHelper=1 SCHEDULE_ASUW=0
rem reg add HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{B8BA155B-1E75-405F-9CB4-8A99615D09DC} /v DisplayVersion /f /reg:64
rem reg add HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{B8BA155B-1E75-405F-9CB4-8A99615D09DC} /v DisplayVersion /t REG_SZ /d 12.1.2.27 /f /reg:64

GOTO :END

:END
CLS
ECHO Installation successfull!
ECHO.
ECHO Exiting…

REM REGISTRY STAMP
%windir%\system32\REG.exe ADD “HKEY_LOCAL_MACHINE\SOFTWARE\MYSOFTWARE\Apple\iTunes\12.1.2.27” /v InstallDate /d “%date% %time%” /t REG_SZ /f
%windir%\system32\REG.exe ADD “HKEY_LOCAL_MACHINE\SOFTWARE\MYSOFTWARE\Apple\iTunes\12.1.2.27” /v InstalledBy /d “%UName%” /t REG_SZ /f

%windir%\system32\EVENTCREATE.exe /T INFORMATION /L Application /ID 777 /d “iTunes 12.1.2.27 package installation COMPLETED SUCCESSFULLY!”

How to image devices with a LANDESK Agent installed

email me

Issue

Imaging a device with a LANDESK Management Agent installed can cause the devices that receive the image to overwrite each other in the database.

 

Cause

LANDESK inventory looks at a Unique ID/Device ID when inserting the scan. This ID is created when the agent installed on the device.

 

Resolution

Important: It is strongly recommended that the LANDESK agent not be included in an image.  The recommended way to install the LANDESK Agent with imaging is to use LANDesk Provisioning and include a Configure Agent action in your provisioning template.  Besides causing duplicate devices, the LANDESK agent is often updated and adding it to the image will quickly cause your image to be outdated.

If the agent must be included in an image or Non-Persistent VDI image, the unique identifiers must be deleted out of the registry prior to the capture of the image.  Before creating an image of the machine do the following:

LANDesk Management Suite 9.0 and later

  1. Install the LANDESK agent, then STOP all LANDESK related services
  2. Delete the following Registry Keys for 32 bit clients:

HKLM\SOFTWARE\Intel\LANDesk\Common Api\UniqueID
          HKLM\SOFTWARE\LANDesk\Common Api\UniqueID

          HKLM\SOFTWARE\LANDesk\Inventory\LogonHistory\Logons
          HKLM\SOFTWARE\LANDesk\ManagementSuite\WinClient\SoftwareMonitoring\MonitorLog contents

         

Delete the following Registry Keys for 64 bit clients:

HKLM\SOFTWARE\Wow6432Node\Intel\LANDesk\Common Api\UniqueID

          HKLM\SOFTWARE\Wow6432Node\LANDesk\Common Api\UniqueID

          HKLM\SOFTWARE\Wow6432Node\LANDesk\Inventory\LogonHistory\Logons

          HKLM\SOFTWARE\Wow6432Node\LANDesk\ManagementSuite\WinClient\SoftwareMonitoring\MonitorLog contents

 

3. On Windows XP delete C:\Documents and Settings\All Users\Application Data\LANDESK (delete the entire directory and subdirectories)

4. On Windows 7, 8, and 8.1 delete C:\ProgramData\LANDesk (delete the entire directory and subdirectories)

5. From the command line (as administrator) in the \LDCLIENT directory run the following

“clientdbutil.exe /create”

6. Verify that a new database, (LDClientDB.db3) was created in the same path as you deleted above

 

Reference

https://community.landesk.com/support/docs/DOC-1688

In addition, it is a good practice to ensure that the image does not contain any DRIVERS.DB3 file.