Return Manufacturer via WMIC

I used this in WinPE to return the manufacturer.

Note, remove the underscore in front of DELLMODE

@echo off
color 0a
cls

set code1=
set code2=

for /f “delims==” %%m in (‘wmic csproduct get vendor ^| find /c /i “Hewlett-Packard”‘) do set /a code1=%%m
if %code1% EQU 1 (
goto :HPMODE
)

for /f “delims==” %%n in (‘wmic csproduct get vendor ^| find /c /i “Dell”‘) do set /a code2=%%n
if %code2% EQU 1 (
goto :_DELLMODE
)

color 0c
Echo Not compatible…this machine cannot be imaged.
pause
exit

:_DELLMODE
echo Dell Mode…
pause
exit

:HPMODE
echo HP Mode…
pause
exit

email me

Simple Email Address Compliance Check

Dim found3

strEmail = “YourEmailAddress@none.com”
Complex3()
msgbox found3

Function Complex3()
Dim found3_1, found3_2

found3 = “false”
‘!
If InStr(strEmail, “@”) <> 0 Then
found3_1 = “true”
else
found3_1 = “false”
End If
If InStr(strEmail, “.”) <> 0 Then
found3_2 = “true”
else
found3_2 = “false”
End If

found3 = found3_1 AND found3_2

end function

email me

Check a Password for Complexity

email me

found1 = ""
found2 = ""

strUserFirst = "ThisIsMyPassword*0"
Complex1
Complex2
msgbox found1 
msgbox found2

Function Complex1()
found1 = "false"
'!
If InStr(strUserFirst, chr(33)) <> 0 Then
   found1 = "true"
End If

'"
If InStr(strUserFirst, chr(34)) <> 0 Then
   found1 = "true"
End If

'#
If InStr(strUserFirst, chr(35)) <> 0 Then
   found1 = "true"
End If

'$
If InStr(strUserFirst, chr(36)) <> 0 Then
   found1 = "true"
End If

'%
If InStr(strUserFirst, chr(37)) <> 0 Then
   found1 = "true"
End If

'&
If InStr(strUserFirst, chr(38)) <> 0 Then
   found1 = "true"
End If

''
If InStr(strUserFirst, chr(39)) <> 0 Then
   found1 = "true"
End If

'(
If InStr(strUserFirst, chr(40)) <> 0 Then
   found1 = "true"
End If


')
If InStr(strUserFirst, chr(41)) <> 0 Then
   found1 = "true"
End If

'*
If InStr(strUserFirst, chr(42)) <> 0 Then
   found1 = "true"
End If

'+
If InStr(strUserFirst, chr(43)) <> 0 Then
   found1 = "true"
End If

',
If InStr(strUserFirst, chr(44)) <> 0 Then
   found1 = "true"
End If

'-
If InStr(strUserFirst, chr(45)) <> 0 Then
   found1 = "true"
End If

'.
If InStr(strUserFirst, chr(46)) <> 0 Then
   found1 = "true"
End If

'/
If InStr(strUserFirst, chr(47)) <> 0 Then
   found1 = "true"
End If


':
If InStr(strUserFirst, chr(58)) <> 0 Then
   found1 = "true"
End If

';
If InStr(strUserFirst, chr(59)) <> 0 Then
   found1 = "true"
End If

'<
If InStr(strUserFirst, chr(60)) <> 0 Then
   found1 = "true"
End If

'=
If InStr(strUserFirst, chr(61)) <> 0 Then
   found1 = "true"
End If

'>
If InStr(strUserFirst, chr(62)) <> 0 Then
   found1 = "true"
End If

'?
If InStr(strUserFirst, chr(63)) <> 0 Then
   found1 = "true"
End If

'@
If InStr(strUserFirst, chr(64)) <> 0 Then
   found1 = "true"
End If

'[
If InStr(strUserFirst, chr(91)) <> 0 Then
   found1 = "true"
End If

'\
If InStr(strUserFirst, chr(92)) <> 0 Then
   found1 = "true"
End If

']
If InStr(strUserFirst, chr(93)) <> 0 Then
   found1 = "true"
End If

'^
If InStr(strUserFirst, chr(94)) <> 0 Then
   found1 = "true"
End If

'_
If InStr(strUserFirst, chr(95)) <> 0 Then
   found1 = "true"
End If

'`
If InStr(strUserFirst, chr(96)) <> 0 Then
   found1 = "true"
End If


'{
If InStr(strUserFirst, chr(123)) <> 0 Then
   found1 = "true"
End If

'|
If InStr(strUserFirst, chr(124)) <> 0 Then
   found1 = "true"
End If

'}
If InStr(strUserFirst, chr(125)) <> 0 Then
   found1 = "true"
End If


'~
If InStr(strUserFirst, chr(126)) <> 0 Then
   found1 = "true"
End If

end function



Function Complex2()
found2 = "false"
'0
If InStr(strUserFirst, chr(48)) <> 0 Then
   found2 = "true"
End If

'1
If InStr(strUserFirst, chr(49)) <> 0 Then
   found2 = "true"
End If

'2
If InStr(strUserFirst, chr(50)) <> 0 Then
   found2 = "true"
End If

'3
If InStr(strUserFirst, chr(51)) <> 0 Then
   found2 = "true"
End If

'4
If InStr(strUserFirst, chr(52)) <> 0 Then
   found2 = "true"
End If

'5
If InStr(strUserFirst, chr(53)) <> 0 Then
   found2 = "true"
End If

'6
If InStr(strUserFirst, chr(54)) <> 0 Then
   found2 = "true"
End If

'7
If InStr(strUserFirst, chr(55)) <> 0 Then
   found2 = "true"
End If


'8
If InStr(strUserFirst, chr(56)) <> 0 Then
   found2 = "true"
End If

'9
If InStr(strUserFirst, chr(57)) <> 0 Then
   found2 = "true"
End If

end function

ASCII codes were originally developed for teletype machines and the first 32 characters are non-printing.

33 ! 71 G 108 l 145 182 219 Û
34 72 H 109 m 146 183 · 220 Ü
35 # 73 I 110 n 147 184 ¸ 221 Ý
$ 74 J 111 o 148 185 ¹ 222 Þ
37 % 75 K 112 p 149 186 º 223 ß
38 & 76 L 113 q 150 187 » 224 à
39 77 M 114 r 151 188 ¼ 225 á
40 ( 78 N 115 s 152 ˜ 189 ½ 226 â
41 ) 79 O 116 t 153 190 ¾ 227 ã
42 * 80 P 117 u 154 š 191 ¿ 228 ä
43 + 81 Q 118 v 155 192 À 229 å
44 , 82 R 119 w 156 œ 193 Á 230 æ
45 83 S 120 x 157  194  231 ç
46 . 84 T 121 y 158 ž 195 Ã 232 è
47 / 85 U 122 z 159 Ÿ 196 Ä 233 é
48 0 86 V 123 { 160   197 Å 234 ê
49 1 87 W 124 | 161 ¡ 198 Æ 235 ë
50 2 88 X 125 } 162 ¢ 199 Ç 236 ì
51 3 89 Y 126 ~ 163 £ 200 È 237 í
52 4 90 Z 127  164 ¤ 201 É 238 î
53 5 91 [ 128 165 ¥ 202 Ê 239 ï
54 6 92 \ 129  166 ¦ 203 Ë 240 ð
55 7 93 ] 130 167 § 204 Ì 241 ñ
56 8 94 ^ 131 ƒ 168 ¨ 205 Í 242 ò
57 9 95 _ 132 169 © 206 Î 243 ó
58 : 96 ` 133 170 ª 207 Ï 244 ô
59 ; 97 a 134 171 « 208 Ð 245 õ
60 < 98 b 135 172 ¬ 209 Ñ 246 ö
61 = 99 c 136 ˆ 173 210 Ò 247 ÷
62 > 100 d 137 174 ® 211 Ó 248 ø
63 ? 101 e 138 Š 175 ¯ 212 Ô 249 ù
64 @ 102 f 139 176 ° 213 Õ 250 ú
65 A 103 g 140 Œ 177 ± 214 Ö 251 û
66 B 104 h 141  178 ² 215 × 252 ü
67 C 105 i 142 Ž 179 ³ 216 Ø 253 ý
68 D 106 j 143  180 ´ 217 Ù 254 þ
69 E 107 k 144  181 µ 218 Ú 255 ÿ
70 F

Scan Text File for Registry Entries

@echo off
setlocal enabledelayedexpansion
set count=1
for /f “delims=” %%a in (data.txt) do (
if !count!==1 set FName=%%a
if !count!==2 set LName=%%a
if !count!==3 set UName=%%a
if !count!==4 set UName=%%a
set /a count+=1
)

%windir%\system32\REG.exe ADD “HKEY_LOCAL_MACHINE\SOFTWARE\Scan” /v “First Name” /t REG_SZ /d “%FNAME%” /f
%windir%\system32\REG.exe ADD “HKEY_LOCAL_MACHINE\SOFTWARE\Scan” /v “Last Name” /t REG_SZ /d “%LNAME%” /f
%windir%\system32\REG.exe ADD “HKEY_LOCAL_MACHINE\SOFTWARE\Scan” /v “User Name” /t REG_SZ /d “%UNAME%” /f
%windir%\system32\REG.exe ADD “HKEY_LOCAL_MACHINE\SOFTWARE\Scan” /v “Email Address” /t REG_SZ /d “%Email%” /f

email me

Resize an Item in PrettyPhoto

email me

Center DIV Vertically and Horizontally

This is how you would center an item vertically and horizontally on your webpage.

Your HTML should look like this:

Your CSS should look like this

#mycontainer{
position: absolute;
top: 50%;
margin-top: -325px;/* half of #mycontent height*/
left: 0;
width: 100%;
}
#mycontent {
width: 1000px;
margin-left: auto;
margin-right: auto;
height: 600px;
}

email me

Return Manufacturer of Workstation

This will return the manufacturer of a computer.

VBScript

On Error Resume Next

strComputer = “.”
Set objWMIService = GetObject(“winmgmts:” & “{impersonationLevel=impersonate}!\\” & strComputer & “\root\cimv2”)
Set colItems = objWMIService.ExecQuery _
(“Select * from Win32_ComputerSystem”)
For Each objItem in colItems
Wscript.Echo “Manufacturer: ” & objItem.Manufacturer
next

Command Line

wmic csproduct get vendor

email me

Return a Specific Line in a Text File

This is how you set a string to a specific line in a text file.

For example, the contents of your sample.txt text file:

This
Is
A
Test

You want to return “Is”

Script

setlocal enabledelayedexpansion
set count=1
for /f “delims=” %%a in (sample.txt) do (
if !count!==2 set strRet=%%a
set /a count+=1
)

echo %strRet%
Pause

email me