Thursday, March 31, 2016

Uncheck "Automatically detect settings", Internet Explorer

This Visual Basic script will uncheck the option:
create file IEautomaticallydetect.vbs with content:
'Example use of IEautomaticallydetect
IEautomaticallydetect  "off"
'IEautomaticallydetect  "show"
'IEautomaticallydetect  "on"
'IEautomaticallydetect  "show"

SUB IEautomaticallydetect (status)

DIM sKey,sValue,binaryVal
Dim oReg
Set oReg=GetObject( "winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")    'For registry operations througout

Const HKCU=&H80000001

sKey = "Software\Microsoft\Windows\CurrentVersion\Internet Settings\Connections"
sValue = "DefaultConnectionSettings"

oReg.GetBinaryValue HKCU, sKey, sValue, binaryVal
select case lcase(status)
case "on"    binaryVal(8) = binaryVal(8) OR 8        'Force Autodetect on
case "off"    binaryVal(8) = binaryVal(8) XOR 8        'Force Autodetect off
case "show"    wscript.echo "Automatically detect is set to " & ((binaryVal(8) and 8) = 8)
case else    wscript.echo "Invalid parameter - IEautomaticallydetect  on, off or show"
end select

if lcase(status)="on" or lcase(status)="off" then oReg.SetBinaryValue HKCU, sKey, sValue, binaryVal

end sub
Create anothe file uncheck-automatically-detect-settings-ie.cmd with content:
cscript "%~dp0IEautomaticallydetect.vbs"

Wednesday, March 30, 2016

Show MySQL database size, Zabbix

Folowing Raspberry Pi as Zabbix Server or Zabbix 3.0.0 appliance for Raspberry Pi it is nice to view details what exactly takes space in MySQL database.

This is such a brialiant way to show how big is your MySQL database:
#download php file to the confiruation directory which is /var/www/html/zabbix/
wget -O /var/www/html/zabbix/size.php

#replace /etc/zabbix/web/zabbix.conf.php with /var/www/html/zabbix/conf/zabbix.conf.php
#this will automatically use MySQL database credentials to connect to the database
sed -i "s/\/etc\/zabbix\/web\/zabbix\.conf\.php/\/var\/www\/html\/zabbix\/conf\/zabbix\.conf\.php/g" /var/www/html/zabbix/size.php
Now go to IP address:
This will show nice summary:

All credits go to:

original size.php content:
 * Zabbix-Database-Size-Calculator
 * @version 0.1
 * @author Jan Bouma | SoHosted
define('ZBXCALC_VERSION', '0.1');

$historyStoragePeriodDays = 7;
$historyBytesPerRecord = 50; // DO NOT CHANGE
$trendStoragePeriodDays = 365;
$trendBytesPerRecord = 60; // DO NOT CHANGE

function formatBytes($size, $precision = 0) {
 $base = log($size, 1024);
 $suffixes = array('', 'KB', 'MB', 'GB', 'TB');   
 return round(pow(1024, $base - floor($base)), $precision) ." ".$suffixes[floor($base)];

if (!file_exists('/etc/zabbix/web/zabbix.conf.php')) {
 echo "Config file <tt>/etc/zabbix/web/zabbix.conf.php</tt> not found!";
$dbh = new PDO('mysql:host=localhost;dbname=zabbix', $DB['USER'], $DB['PASSWORD']);
<!DOCTYPE html>
<html lang='en'>
 <meta charset='UTF-8' />
 <title>Zabbix Database Size Calculator <?=ZBXCALC_VERSION ?></title>
 <link rel="stylesheet" href="">
 <link rel="stylesheet" href="">
 <script src=""></script>
<div class='container'>
 <h1>Zabbix Database Size Calculator <?=ZBXCALC_VERSION ?></h1>
 <div class='row'>
  <div class='col-lg-8'>
  <h2>Required storage <small>for history &amp; trends</small></h2>
  <p>Each monitored item is saved in de database per refresh rate. The table below lists the required storage for history and trend records.</p>
  <p>The firsti two columns show the actual amount of items and there refresh rate in Zabbix. The formula used to calculate the required storage is: <tt>days * (items / delay) * 24 * 3600 * bytes</tt></p>
  <table class='table table-condensed'>
    <th>Refresh rate</th>
    <th colspan='6'><em>History</em></th>
$historyTotalBytes = 0;
$historyTotalRecords = 0;
$historyTotalItems = 0;

foreach ($dbh->query('SELECT COUNT(itemid) AS count, delay FROM items GROUP BY delay ORDER BY delay') as $row) {
 $itemCount = $row['count'];
 $itemDelay = $row['delay'];

 $historyTotalItems += $row['count'];
 $historyRecordsRequired = $historyStoragePeriodDays * ($itemCount / $itemDelay) * 24 * 3600;
 $historyTotalRecords += $historyRecordsRequired;
 $historyBytesRequired = $historyRecordsRequired * $historyBytesPerRecord;
 $historyTotalBytes += $historyBytesRequired;
 echo "\t<tr>\n"
  ."\t\t<td class='text-right'>".$itemCount."</td>\n"
  ."\t\t<td>".$historyStoragePeriodDays." &times; (".$itemCount." / ".$itemDelay.") &times; 24 &times; 3600 &times; ".$historyBytesPerRecord."</td>\n"
  ."\t\t<td class='text-right'>".$historyRecordsRequired."</td>\n"
  ."\t\t<td class='text-right'>".$historyBytesRequired."</td>\n"
   <tr class='active'>
    <td colspan='3' class='text-right'>Total history</td>
    <td class='text-right'><?php echo $historyTotalRecords ?></td>
    <td class='text-right'><?php echo $historyTotalBytes ?></td>
    <td><?php echo formatBytes($historyTotalBytes) ?></td>
$trendRecordsRequired = $trendStoragePeriodDays * ($historyTotalItems / 3600) * 24 * 3600;
$trendBytesRequired = $trendRecordsRequired * 60;
$trendGigabytesCount = $trendBytesRequired / 1024 / 1024 / 1024;
    <th colspan='6'><em>Trends</em></th>
echo "\t<tr>\n"
 ."\t\t<td class='text-right'>".$historyTotalItems."</td>\n"
 ."\t\t<td>".$trendStoragePeriodDays." &times; (".$historyTotalItems." / 3600) &times; 24 &times; 3600 &times; ".$trendBytesPerRecord."</td>\n"
 ."\t\t<td class='text-right'>".$trendRecordsRequired."</td>\n"
 ."\t\t<td class='text-right'>".$trendBytesRequired."</td>\n"
   <tr class='active'>
    <td colspan='3' class='text-right'>Total history + trends</td>
    <td class='text-right'><?php echo $historyTotalRecords + $trendRecordsRequired ?></td>
    <td class='text-right'><?php echo $historyTotalBytes + $trendBytesRequired ?></td>
    <td><?php echo formatBytes(($historyTotalBytes + $trendBytesRequired)) ?></td>

<h2>Database table size <small>actual table status</small></h2>
<p>This table lists the actual table size of the Zabbix database tables</p>
<table class='table table-condensed'>
  <th>Data length</th>
  <th>Index length</th>
  <th>Data free</th>
  <th>Total GB</th>
$tables = array(

foreach ($dbh->query('SHOW TABLE STATUS') as $row) {
 if (!in_array($row['Name'],$tables)) {

 $tableData = $row['Data_length'];
 $tableIndex = $row['Index_length'];
 $tableFree = $row['Data_free'];
 $tableTotal = $tableData + $tableIndex + $tableFree;
 $tableTotalGB = $tableTotal / 1024 / 1024 / 1024;
 echo "\t<tr>\n"
  ."\t\t<td class='text-right'>".$tableData."</td>\n"
  ."\t\t<td class='text-right'>".$tableIndex."</td>\n"
  ."\t\t<td class='text-right'>".$tableFree."</td>\n"
  ."\t\t<td class='text-right'>".$tableTotal."</td>\n"
  ."\t\t<td class='text-right'>".formatBytes($tableTotal)."</td>\n"
  <div class='col-lg-4'>
   <p>Variables used to calculate the required storage</p>
   <div class='panel panel-default'>
    <table class='table table-condensed'>
      <td>History storage period:</td>
      <td><?php echo $historyStoragePeriodDays; ?></td>
      <td>Trend storage period:</td>
      <td><?php echo $trendStoragePeriodDays; ?></td>
      <td>History bytes per record:</td>
      <td><?php echo $historyBytesPerRecord; ?></td>
      <td>Trend bytes per record:</td>
      <td><?php echo $trendBytesPerRecord; ?></td>
  <hr />
   <strong>Author: Jan Bouma (acropia)</strong><br />
   GitHub repo: <a href='' target='_blank'></a>

Tuesday, March 29, 2016

Install Google Chrome on CentOS 7

Move to the root account:
sudo su
Add repository:
cat > /etc/yum.repos.d/google-chrome.repo <<EOT
Check if there is any Google Chrome version available now:
yum info google-chrome-stable
This will report something like:
Name        : google-chrome-stable
Arch        : x86_64
Version     : 49.0.2623.110
Release     : 1
Size        : 46 M
Repo        : google-chrome/x86_64
Summary     : Google Chrome
URL         :
License     : Multiple, see
Description : The web browser from Google
Install Google Chrome:
yum install google-chrome-stable -y

Sunday, March 27, 2016

Error 7054 - The system has reached its licensed logon limit

I am trying to romote control user session in Windows Server 2008 R2.
I have Windows Server 2012 domain controller which host licensing server.

Turns out it is possible to control user session with another Windows 2008 R2 server using "Remote Desktop Session manager":

If you find this useful and you do not leave a comment then you will die.

If this was not helpful do not worry. You will live a very healthy life ;)

Monday, March 21, 2016

Set default registry keys in HKCU new user profile

I were using this method back in reduce ntuser.dat but this is such a big deal for new post.

I have this problem in Windows Server 2008 R2:
I have configured application to run at user startup.
This means that explorer.exe is not loaded which cause very weird color theme in new user profile.

To solve this situation you have to backup color pattern which you are satisfied with:
reg export "HKCU\Control Panel\Colors" "%userprofile%\Desktop\colors.reg"
Now lets modify new user default registry package:
Open regedit in "Run As Administrator" mode.


Go for [File] -> [Load Hive...]

Select C:\Users\Default\NTUSER.DAT

Set name like pillow

Now the pillow is loaded:

Go to Colors section and select [Copy Key Name]

Open colors.reg in notepad and replace:
HKEY_CURRENT_USER\Control Panel\Colors
with your key value for example:
HKEY_LOCAL_MACHINE\pillow\Control Panel\Colors
Remember to keep the square brackets! Save the file! At the end file looks like:
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\pillow\Control Panel\Colors]
"Background"="58 110 165"
"Scrollbar"="212 208 200"
"ActiveTitle"="10 36 106"
"InactiveTitle"="128 128 128"
"Menu"="212 208 200"
"Window"="255 255 255"
"WindowFrame"="0 0 0"
"MenuText"="0 0 0"
"WindowText"="0 0 0"
"TitleText"="255 255 255"
"ActiveBorder"="212 208 200"
"InactiveBorder"="212 208 200"
"AppWorkspace"="128 128 128"
"Hilight"="10 36 106"
"HilightText"="255 255 255"
"ButtonFace"="212 208 200"
"ButtonShadow"="128 128 128"
"GrayText"="128 128 128"
"ButtonText"="0 0 0"
"InactiveTitleText"="212 208 200"
"ButtonHilight"="255 255 255"
"ButtonDkShadow"="64 64 64"
"ButtonLight"="212 208 200"
"InfoText"="0 0 0"
"InfoWindow"="255 255 225"
"ButtonAlternateFace"="181 181 181"
"HotTrackingColor"="0 0 128"
"GradientActiveTitle"="166 202 240"
"GradientInactiveTitle"="192 192 192"
"MenuHilight"="10 36 106"
"MenuBar"="212 208 200"
Now go [File] -> [Import...] and select colors.reg
Make sure something has been imported:

Select again pillow and go for [File] -> [Unload Hive...]

Delete all old user from computer:
use "Run As Administrator" mode.

Friday, March 18, 2016

Integrate Proxy Settings, Windows Server 2008 R2

I did not found option to integrate proxy settings via group policy for Windows Server 2008 R2. As an workaround i found that there is a tool to create windows explorer 11 custom installation and you can set this option there.

To work with this solution:

Download Internet Explorer Administration Kit 10 (IEAK 10)

Now open:
Start -> All Programms -> Windows IEAK 11 ->
Internet Explorer Customization Wizard 11

Folowing on screen instructions you have to select which kind of package you want to create:

Let the wizard know that there can be situation that internet explorer 11 is already installed and in this case you want to only push the settings:

If you really want to only integrate proxy settings then just select "Connection Customization":

Press "Synchronize" to download internet explorer source files:

And finally you open internet explorer dialog:

Goto "Lan settings":

You can only set the lan settings:

After all go to your C:\builds\DDMMYYYY\BrndOnly\AMD64_WIN7\EN-US and you got files:
Use msi file to deploy settings:
%systemroot%\system32\msiexec.exe /i IE11-Setup-Branding.msi /qb

Thursday, March 17, 2016

Tuesday, March 15, 2016

if comparing float, linux shell, awk

if a is greater than b:
a=$(echo "6.3")
b=$(echo "5.95")
var=$(awk 'BEGIN{ print "'$b'"<"'$a'" }')
if [ "$var" -eq 1 ]; then
echo $a is greater than $b
echo $b is greater then $a
if b is greater than a:
a=$(echo "16.3")
b=$(echo "25.95")
var=$(awk 'BEGIN{ print "'$b'"<"'$a'" }')
if [ "$var" -eq 1 ]; then
echo $a is greater than $b
echo $b is greater then $a
if b and a is equal:
a=$(echo "6.3")
b=$(echo "6.3")
var=$(awk 'BEGIN{ print "'$b'"=="'$a'" }')
if [ "$var" -eq 0 ]; then
echo $a and $b is different
echo $b and $a is equal

Monday, March 14, 2016

32-bit Office 2013 quick deployment guide

Before you work with this scenario
make sure this key exists on computer where office is installed:
Lauch setup.exe /admin and create your administrative profile.
Save the profile as silent.msp in directory where setup.exe is having a good time.

office 2013 x86 silent install using administrative msp file

@echo off
setlocal EnableDelayedExpansion
set proplus=Office15.PROPLUS
set u=Microsoft\Windows\CurrentVersion\Uninstall

if not "%ProgramFiles(x86)%"=="" (
reg query %sw%\Wow6432Node\%u%\%proplus% > nul 2>&1
if !errorlevel!==0 (
echo 32-bit office detected on 64-bit windows
goto exit

reg query %sw%\%u%\%proplus% > nul 2>&1
if !errorlevel!==0 (
echo native office detected based on windows architecture
goto exit

echo installing 32-bit office..
start /wait "" "%~dp0setup.exe" /adminfile "%~dp0silent.msp"
reg add "HKCU\Software\Microsoft\Office\15.0\Common\General" /v shownfirstrunoptin /t REG_DWORD /d 1 /f > nul 2>&1
reg add "HKCU\Software\Microsoft\Office\15.0\FirstRun" /v BootedRTM /t REG_DWORD /d 1 /f > nul 2>&1
reg add "HKCU\Software\Microsoft\Office\15.0\FirstRun" /v disablemovie /t REG_DWORD /d 1 /f > nul 2>&1
reg add "HKCU\Software\Microsoft\Office\15.0\Common\PTWatson" /v PTWOptIn /t REG_DWORD /d 1 /f > nul 2>&1
reg add "HKCU\Software\Microsoft\Office\15.0\Common" /v qmenable /t REG_DWORD /d 1 /f > nul 2>&1


office 2013 x86 silent uninstall using xml file

@echo off
setlocal EnableDelayedExpansion
set proplus=Office15.PROPLUS
set u=Microsoft\Windows\CurrentVersion\Uninstall

if not "%ProgramFiles(x86)%"=="" (
reg query %sw%\Wow6432Node\%u%\%proplus% > nul 2>&1
if !errorlevel!==0 (
echo 32-bit office detected on 64-bit windows
goto uninstall

reg query %sw%\%u%\%proplus% > nul 2>&1
if !errorlevel!==0 (
echo native office detected based on windows architecture
goto exit

goto exit

echo uninstalling 32-bit office..
start /wait "" "%~dp0setup.exe" /uninstall ProPlus /config "%~dp0ProPlusUninstall.xml"

<Configuration Product="ProPlus">
<Display Level="none" CompletionNotice="no" SuppressModal="yes" AcceptEula="yes" />
<Setting Id="SETUP_REBOOT" Value="AutoAlways" />

Thursday, March 10, 2016

Monday, March 7, 2016

Midori Browser acts like Safari on Mac OS X

To prevent this thing to happen it is possible to use these other options:
midori -e identify-as=MIDORI_IDENT_FIREFOX
midori -e identify-as=MIDORI_IDENT_CHROME
midori -e identify-as=MIDORI_IDENT_EXPLORER

Saturday, March 5, 2016

SumatraPDF new version detect

Today i am creating a version detect for SumatraPDF.
I do not use this application very often but my wife use it for ePub books.

This is first time when i look for content into javascript file.
For example the latest version number of SumatraPDF can be found under:

Every file are hosted with base url:
Then comes version number like 3.1.1.

At the end the url file is completed with four other scenarious like:
So at the end we got these links:
The whole project can be found under:

And the result of course under:

Friday, March 4, 2016

Midori socks proxy, tor, tsocks, Raspberry Pi

I was struggling this for a while. By default Midori was not option to use socks5 proxy option. I needed this option so i can connect to the tor network which usually is at port 9050. This solution actually uses socks4.

This is tested on fresh 2016-02-26-raspbian-jessie.img.

Move to the super user:
sudo su
Update system:
apt-get update -y && apt-get upgrade -y
Install tsocks tunnel future:
apt-get install tsocks -y
Configure tsocks to use default tor port:
cat > /etc/tsocks.conf <<EOT
server =
server_port = 9050
local =
local =
Add user pi to tor group. This is required for unattended install:
sed -ri '$adebian-tor:x:111:pi' /etc/group
Install tor network:
apt-get install vidalia -y
Install Midori web browser:
apt-get install midori -y
To execute midori with tor network use:
tsocks midori -a

Thursday, March 3, 2016

MAC address exception, Windows, command line

Today i want to limit script execution based on client MAC address.

I use gnu grep for more production and less code.

This is how i found MAC address for active interface.
Change the basic octets to satisfy your needs:
for /f "tokens=12 delims= " %%a in ('^
ipconfig -all ^|
"%~dp0grep.exe" -m1 -B6 "IPv4 Address.*192\.168\.[0-9]\+\." ^|
"%~dp0grep.exe" "Physical Address"') do (
echo %%a
And now the limitation:
I create a file exeption-list.txt with content:
And the final script for production:
setlocal EnableDelayedExpansion
for /f "tokens=12 delims= " %%a in ('^
ipconfig -all ^|
"%~dp0grep.exe" -m1 -B6 "IPv4 Address.*192\.168\.[0-9]\+\." ^|
"%~dp0grep.exe" "Physical Address"') do (
type "%~dp0exeption-list.txt" | find "%%a"
if !errorlevel!==0 echo MAC found

Wednesday, March 2, 2016

Remove PDFCreator 2 welcome screen

I have made universal script to remove PDFCreator welcome screen:

user-startup-script.cmd - this script must be execute with simple user permission.
@echo off
setlocal EnableDelayedExpansion
set path=%path%;%~dp0
set program=HKLM\SOFTWARE\pdfforge\PDFCreator\Program

echo Checking if PDFCreator is even installed..
reg query "%program%" > nul 2>&1

if !errorlevel!==0 (
echo PDFCreator found. Reading the version now..

reg query "%program%" /v ApplicationVersion |^
sed "s/^.*REG_SZ[ \t]*//" |^
grep -v "[a-zA-Z]" |^
grep "[0-9\.]\+"

if !errorlevel!==0 (
echo Reading version and format value for welcome key..

for /f "tokens=*" %%a in ('^
reg query "%program%" /v ApplicationVersion ^|
sed "s/^.*REG_SZ[ \t]*//" ^|
grep -v "[a-zA-Z]" ^|
grep "[0-9\.]\+" ^|
sed "s/^/v/;s/\./ Build /3"') do (

echo Inserting value in current user profile..

reg add "HKCU\Software\pdfforge\PDFCreator" ^
/v LatestWelcomeVersion /t REG_SZ /d "%%a" /f > nul 2>&1
if !errorlevel!==0 echo Done.


This is tested and works on versions:
This is tested and not works on version 2.1.2 cause it keeps the settings under:
All together:

Lets see how long this works!