Thursday, December 12, 2013

change system SQL database connection

In windows you can create a database connection for your front end program to use.  Well as with all things in life things change, you decide to get a new database server, you messed up on the initial imaging of the workstations, you decided to expand or consolidate your database servers.  Instead of having to go around to each desktop and dig through control panel on each one to edit the database connection, here's a script to change the server.

This does not create a new database connection on each computer, for that you'll probably want to do configuration through control panel on one of the computers and then export it out the HKLM\SOFTWARE\Wow6432Node\ODBC\ODBC.INI or HKLM\SOFTWARE\ODBC\ODBC.INI keys to a file.

If your database is something other then CMS you'll need to change the key path referenced below.




@echo off
if "%1" == "" goto needarguments
for /f "tokens=2" %%W in ('date /t') do set dater=%%W
for /f "tokens=1-3 delims=/" %%d in ('echo %dater%') do set curdate=%%f%%d%%e
rem what we're changing the CMS database server to.
set dsnserver=newprod



:nextcomp
set remotecomp=%1
rem need to do some ping checks and stuff
echo updating %1 at %time%


for /f "tokens=2 skip=1 delims==" %%q in ('ping -n 1 %1') do set pingtimer=%%q
for /f "tokens=1 delims=m" %%s in ('echo %pingtimer%') do set pingtime1=%%s


if "%pingtime1%" == "1 Received " set pingtime1=down
if "%pingtime1%" == "down" echo %1 down at %date% %time% >> pc-down-dsn-%curdate%.lst
if "%pingtime1%" == "down" goto thiscompfinished



rem this works only if changing the server, if no dsn/odbc connection is
rem yet set up, you'll need to add more registry keys then just this one.
rem echo on
if exist \\%1\c$\windows\syswow64 reg add "\\%1\HKLM\SOFTWARE\Wow6432Node\ODBC\ODBC.INI\CMS" /v Server /t reg_sz /d %dsnserver% /f
if not exist \\%1\c$\windows\syswow64 reg add "\\%1\HKLM\SOFTWARE\ODBC\ODBC.INI\CMS" /v Server /t reg_sz /d %dsnserver% /f
if errorlevel 1 echo %1 had error updating dsn on %date% %time% >> pc-error-dsn-%curdate%.lst
if errorlevel 0 echo %1 updated dsn to %dsnserver% on %date% %time% >> pc-fixed-dsn-%curdate%.lst
echo off


:thiscompfinished
shift
if not "%1" == "" goto nextcomp
echo finished at %date% %time%
goto end


:needarguments
echo usage: %0 comp1 comp2 comp3 etc...
echo make sure to not use any \\







:end

Monday, December 9, 2013

IE Tracking protection lists

Where I'm at we have a web filtering device that will display a full pdf with the employer's terms of service if you go to a website we have blocked.  Problem is one of those is facebook, and if you go to say a news site and it has a facebook like button, the news site isn't blocked, but you still get a huge pdf file come up on your screen.

Thankfully if you're running a newer version of Internet Explorer, there is a feature called "Tracking Protection Lists", while meant to improve your privacy, they can also disable the facebook "like" button that you find on many websites. Problem is digging through all of IE's settings can be a pain.  So here is a simple internal web page for users to go to load the page (just have to click a button on the page).

note: If you're using IIS to serve this you will need to go into the server's "MIME Types" and add
the .tpl extension.  I labeled it as "application/ie", IIS apparently won't serve unknown MIME types.

First file is the tracking protection list file that we want IE to load.
#------------------don't include this line in facebook-block.tpl ---------------------------
msFilterList
: Expires = 5
# blocked strings
- like.php
# domain rules
-d facebook.com
-d facebook.net
# from http://anglachelg.blogspot.com/2011/04/create-your-own-tpl-for-ie9.html
#------------------don't include this line in facebook-block.tpl ---------------------------

------index.html --- don't include this line ---------------------
<!DOCTYPE html />
<html >
<head>
<!--- from http://msdn.microsoft.com/en-us/library/hh273399%28v=vs.85%29.aspx -->
    <title>Internet Explorer 9 Tracking Protection list loader</title>
    <script type="text/javascript">
 
    function checkTP() {
    //checks whether Tracking Protection has been enabled (any list is on)
        if (window.external.msTrackingProtectionEnabled())
      {
            document.getElementById("results").innerHTML = "Tracking protection is: ON";
        } else {
            document.getElementById("results").innerHTML = "Tracking protection is: OFF";
        }
    }

    //loads a list specified by input field
    function loadTPFile() {
        var URL = document.getElementById("tplfile").value;      
        var description = 'Facebook blocking Tracking Protection List';      
        window.external.msAddTrackingProtectionList(URL, description);
    }
</script>

</head>
<body>
<!---- First check that you have tracking protection enabled by click the
"check tracking protection" button
<div>
  <button onclick="checkTP();">Check tracking protection</button>
  <span id="results">Tracking protection is: </span>
</div>
<p />
Remember that you need to have tracking protection "on" for this to work
if tracking protection is off, go to: <br>
tools, tracking protection, select "Your Personalized List" and click enable, close, <br>
then click on the "check tracking protection" button again.

--->
<p />
This is for blocking the facebook like button (and facebook's other tracking mechanisims),
that are on many websites nowdays, which cause the company's usage policy to pop up.  To stop this: <br>
click on "load TPL file"
and click on the "add list" button
<p />
<div>
  <button onclick="loadTPFile();">Load TPL file</button>
  <input id= "tplfile" type="text" value="facebook-block.tpl" size="60" />
</div>

<p />
Remember if you go to the facebook.com website itself you will still get a copy of the company's
Internet usage policy poping up.
</body>
</html>