Happy Programmers’ Day!

Wikipedia Page

Happy SysAdmin Day!

Official SysAdmin Day Site

Wikipedia Page

Stream Media with IIS Media Services

In this tutorial we will take a video file and encode it to IIS Smooth Streaming, then publish those files with IIS Media Services.  There are a few things that need to be installed before we can proceed:

  1. Launch Microsoft Expression Encoder and select Transcoding Project.
  2. Click the Import button below and select your video/audio file.
  3. Switch the Output Format to IIS Smooth Streaming, and click Encode.

expression

  1. After a length of time, depending on the size of the file, your encoding will be complete and you can close out of Expression Encoder.
  2. Go to: C:\Users\USERNAME\Documents\Expression\Expression Encoder\Output
  3. Open the newly created stream folder and copy the contents into: C:\inetpub\wwwroot\YOUR_DIRECTORY
  4. Open the extracted files from the SmoothStreamingPlayer.exe and copy those files to: C:\inetpub\wwwroot\YOUR_DIRECTORY
  5. Rename the SmoothStreamingPlayer.html file to index.html, then edit the file and replace the following code:
<param name="InitParams" value="selectedcaptionstream=textstream_eng,mediaurl=http://YOUR_SERVER/YOUR_DIRECTORY/YOUR_ISM_FILE.ism/manifest" />
  1.  You’re all done!  Now test it out by going to: http://YOUR_SERVER/YOUR_DIRECTORY

stream

  1. To view your published files launch IIS, drill down to your website directory and select Content View.

content

Simple Robocopy Backup Script

This script is identical to my previous Simple XCopy Backup Script, except it uses the new robocopy command that comes installed on Windows Vista, 7 and 8.


@echo off
:: variables
set drive=E:\
set backupcmd=robocopy /mir /z /fft

echo ### Backing up Documents...
%backupcmd% "C:\Users\ENTER USERNAME HERE" "%drive%"

echo Backup Complete!
@pause

The difference between xcopy and robocopy is overall performance. Robocopy can tolerate network interruptions, has built in bandwidth throttling, and can copy multiple large files that could otherwise crash XCopy. You can read more information on Robocopy on Wikipedia and Microsoft TechNet.

Removing cached AD passwords in IE

Scenario:

Your company has a web enabled Microsoft app (Outlook Web Access, SharePoint, etc…) that passes your Active Directory credentials internally so you don’t have to login twice (Once to get on the computer and again to access the app).

Then your company decides to publish this app outside of your facility allowing you to directly access it from home, but because you’re not on the company network when you’re at home you have to log into the app using your AD credentials.

You decide that logging in is “for the birds” and set Internet Explorer to save your AD username and password so you don’t have to enter it in.  Success!

This carries on for a while until your networks security policy is forcing you to change your password, which is ok with you.  You’ll just clear out your IE saved usernames and passwords and save it all back with your new password.

But wait there seems to be a problem, you’re clearing out IE but it’s not clearing out your AD credentials.  What do you do?

Solution:

For starters you should never save your AD credentials in IE.  IE handles your AD credentials and your generic website credentials completely differently.   When you go to generic website like Amazon or Google and tell it to save your username and password to those sites, it stores those credential in the registry.  Then when you tell IE to clear all of your saved passwords it clears out the registry.  Your AD credentials are not stored in the registry; they are stored in an encrypted NTLM hash file stored in your user folder.

Luckily Windows 7 introduced us to the “Credential Manager”, which is found in the Control Panel.  This allows us to remove AD and generic credentials that are stored on your computer with ease.  But for those that are still running Windows XP below are the steps to removing that cached AD account.

  1. Go to: C:\Documents and Settings\YOUR USERNAME\Application Data\Microsoft\Credentials\<SID>\Credentials
  2. Make a copy, then delete the original.
  3. Reboot the computer.

Update:

Since the introduction of Credentials Manager in Windows 7 and up, you can now manage your saved AD accounts.  Credentials Manager is located in the Control Panel.

Simple PHP Form Security

Below is a simple PHP function that I use to strip any dangerous code from my input boxes.


<?php

// make our user input safe to output

function safe_output($string){

$string = trim($string);

$string = strip_tags($string);

$string = htmlspecialchars($string);

return $string;

}

// retrieve form data

$phrase = safe_output($_POST['phrase']);

?>

First we are going to create a function called “safe_output”, and within that function we are going to perform a set of statements that will trim and strip any whitespace and code from our textbox and give us just the raw string.

Within our function we are going to create the variable $string.  Then we are going to pass $string through the “trim” function which will remove any whitespace before and after our string (Example: “Bill Gates     “ becomes “Bill Gates”).

Next we will pass our variable through the “strip_tags” function which will strip out any HTML and PHP tags from our string (Example: “<html><body>Bill Gates</body></html>” becomes “Bill Gates”).

Then finally we will pass our variable through the “htmlspecialchars” function which will convert any special characters to HTML entities (Example: “&” will become “&amp”, and “>” will become “&gt”, etc…).

Lastly we create a new variable called “$phrase” that passes the string from our form through our safe_output function.

Windows GodMode

In this “How To” we are going to create a shortcut to access the hidden “GodMode” in Windows 7 and 8. This hidden “GodMode” is just a shortcut to all of Windows various control settings in a nice convenient list.

  1. Create a new folder on your desktop.
  2. Rename the folder with the name below:

GodMode.{ED7BA470-8E54-465E-825C-99712043E01C}

  1.  Once the folder has been renamed the icon will resemble a control panel and the folder will be named “GodMode”.
  2. Open “GodMode” and you will see dozens of control settings for you to choose from.

Simple XCopy Backup Script

In this “How To” we are going to write a simple bat file that will copy your user folder (My Documents, Favorites, Desktop, …) to another drive space (Network Share, USB External Hard Drive, …). The first time this script runs it does a full back up and depending on how large your user folder is it could take a long time. The next time you run the script it will only grab new or updated files making the copy that much faster. What’s nice about this script is that you can build onto it with other directories (Game Saves, Program Settings).

  1. Open Notepad.
  2. Copy the following code into Notepad.

@echo off
:: variables
set drive=E:\
set backupcmd=xcopy /s /c /d /e /h /i /r /k /y

echo ### Backing up Documents...
%backupcmd% "C:\Users\ENTER USERNAME HERE" "%drive%"

echo Backup Complete!
@pause

  1.  Go to File/Save As.
  2. Change the “Save as type” to “All Files”.
  3. Now save this file to your desktop as xcopy backup.bat.

Now before we run this script we need to edit the code to fit with your situation. Right click your script and select “Edit”, it should now open in Notepad. Let’s look at a few lines of code to better understand what is taking place here.

In this first set of code we are creating two variables, drive and backupcmd. You are going to want to set “drive” to were you want your backup to go, in this example our backup is being copied to the E:\ drive. The backupcmd variable is simply our xcopy command with a few triggers, these triggers help copy only new files or updated files and also helps skip any read only errors that may come up. If you want a better explanation of what these triggers are, open Command Prompt and type xcopy /? and press enter.


:: variables
set drive=E:\
set backupcmd=xcopy /s /c /d /e /h /i /r /k /y

The next batch of code is were the action happens. The first line is simply printing “### Backing up Documents…”, just to let the user know what it’s doing. When you add other directories to backup here you will want to include these messages to see how far into the script it is, like “###Backing up Diablo II…” The next line of code we get to see our two variables in action. First we run our backupcmd command (the xcopy with triggers), then we tell what directory we are backing up, in this example our user folder. BTW where it says “ENTER USERNAME HERE” do just that, enter your user name. If you are running Windows XP or older then you need to change this line to C:\Documents and Settings\ENTER USERNAME HERE. Then this line of code finishes it off with our drive variable. So ultimately we are telling command prompt to xcopy our user folder to our backup drive space (Example: drive E:\). The last line simply tells the user that your backup has completed.


echo ### Backing up Documents...
%backupcmd% "C:\Users\ENTER USERNAME HERE" "%drive%"

echo Backup Complete!

Now that your script has been edited to your liking, go ahead and save the final script and run it from your desktop by double clicking on it. You will see Command Prompt open and a list of files copying over to your backup drive space. It will tell you “Backup Complete!” when it finishes. Below is the same script with added directories to give you a better idea on how far you can take this.


@echo off
:: variables
set drive=E:\Ryan's Backup
set backupcmd=xcopy /s /c /d /e /h /i /r /k /y

echo ### Backing up Documents...
%backupcmd% "C:\Users\ryanj" "%drive%"

echo ### Backing up Diablo II...
%backupcmd% "C:\Program Files\Diablo II\save" "%drive%"

echo ### Backing up Local Websites...
%backupcmd% "C:\wamp\www" "%drive%"

echo Backup Complete!
@pause

Hello World!

Hello World!

© 2016 Ryan Janis

Theme by Anders NorénUp ↑