Friday, December 17, 2010

Create Windows Share on a remote computer

This subroutine will add a Windows (or NT) share to any computer provided you have a user with permission on that machine.
Private Sub CreateShare(strShareName, strPath, strDescription, strComputer, strDomain, strUser, strPassword) 
    Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator") 
    Set objSWbemServices = objSWbemLocator.ConnectServer(strComputer, _
         "root\cimv2", strUser, strPassword, "MS_409", "ntlmdomain:" + strDomain) 
    Set colSwbemObjectSet = objSWbemServices.InstancesOf("Win32_Share") 

    For each objSWbem in colSwbemObjectSet 
        If(objSWbem.name = strShareName)Then  
            blnShareExists = True 
            Exit For 
        Else            
            blnShareExists = False 
        End If 
    Next  

    If (blnShareExists = False)Then 
        set objSWbemObject = objSWbemServices.Get("Win32_Share")  
        intRet = objSWbemObject.Create(strPath, strShareName, 0, _
            10, strDescription) 
    End If 
    msgbox(intret) 
End Sub
Sample call:
CreateShare "Share1", "D:\mydir", "this is mydir", "MyComp", "MyDomain.Net", "MyUser" , "MyPassword"

Thursday, December 16, 2010

Map Network Drive with a users credentials


Three quick and easy ways to Map a UNC path to a local drive. The samples below (DOS, VBS, PowerShell) map the Q: drive to a network path using different credentials. you can also remove the parameters for credentials and it will create the connection with the current logged-on user.

DOS
NET USE Q: \\MyUnc\Path /USER:MyUser MyPassword

VBS

strDrive = "Q:"
strUNC = "\\MyUnc\Path"
strProfile = "False"   ' Mapping (not) stored in user Profile
strUser = "MyUser"
strPassword = "MyPassword"
Set objNetwork = CreateObject("WScript.Network") 
objNetwork.MapNetworkDrive strDrive, strUNC, strProfile, strUser, strPassword 

Powershell

$Drive = "Q:"
$UNC = "\\MyUnc\Path"
$Profile = "False"
$User = "MyUser"
$Password = "MyPassord"
$Network = New-Object -com WScript.Network; 
$Network.mapnetworkdrive($Drive,$Unc, $Profile, $User, $Password)

The code above is basically the same as done in VBS, You can also make the DOS call in Powershell.

Sunday, December 5, 2010

Automated configuration tool (get me out of *.config hell!)

I have been living in config file hell for a while, its a case of no one really owning the the release engineer role/release process at my work. This has caused a lot of troubles when promoting builds (DEV -> QA -> STG -> PROD)  Out of this hell I have written a tool for making bulk changes to XML based configuration files.

The tool, I called it ConfigDriver.exe uses XPath to find and modify XML based files. Any XPath query that returns a single node will work.  It uses a "|" delimited file as the change source and can be configured two ways.

File layout definition:
1) To change a Single node value
File Name Path | XPath Query | Node Value

2) To change an attribute value
File Name Path | XPath Query | Attribute Name | Attribute Value

Below are some sample calls
..\..\sampleFile.xml|/ConfigDriver/SampleOne|Change one node value
..\..\sampleFile.xml|/ConfigDriver/SampleTwo/Attrib[@name='item1']|description|Change one specific attribute value
..\..\sampleFile.xml|/ConfigDriver/SampleThree[@name='SpecificNone']|Change one node value by name

Here is a link to the program ConfigDriver.exe



Thursday, November 18, 2010

Gartner Says Worldwide Mobile Device Sales Grew 13.8 Percent in Second Quarter of 2010, But Competition Drove Prices Down

Gartner has "Microsoft Windows Mobile" at 5% market share Second quarter of 2010, I'm predicting "Windows 7 Phone" Will have at least 5% in the Q3! I cant wait to see the numbers, I'm loving my Windows 7 Phone.

Look at the Android jump from 2009 to 2010, who didn't see that coming!

Gartner Says Worldwide Mobile Device Sales Grew 13.8 Percent in Second Quarter of 2010, But Competition Drove Prices Down

Table 2
Worldwide Smartphone Sales to End Users by Operating System in 2Q10 (Thousands of Units)

Operating System

2Q10

Units

2Q10 Market Share (%)

2Q09

Units

2Q09 Market Share (%)

Symbian

25,386.8

41.2

20,880.8

51.0

Research In Motion

11,228.8

18.2

7,782.2

19.0

Android

10,606.1

17.2

755.9

1.8

iOS

8,743.0

14.2

5,325.0

13.0

Microsoft Windows Mobile

3,096.4

5.0

3,829.7

9.3

Linux

1,503.1

2.4

1,901.1

4.6

Other OSs

1,084.8

1.8

497.1

1.2

Total

61,649.1

100.0

40,971.8

100.0

Source: Gartner (August 2010)

Wednesday, November 10, 2010

I got my new Windows 7 Phone, Samsung Focus 8GB

I just got my new Windows 7 Phone, Samsung Focus 8GB from Costco yesterday.   

Picture of the phone at the lock screen.
Photo taken by my iPhone 3GS

Thursday, October 28, 2010

Hi Low game Mark I

I just finished my first go at creating a card game for the Windows 7 Phone. I chose to do Hi Low because it had the easiest rules to remember aka easiest game play to program. The coolest bit of this app is that I didn't use images for the cards, instead I embedded a custom true-type font into the app. It works well but has some formating issues. I didn't realize how hard it is to play Hi Low... The Best I have scored is 12 cards so far.

Monday, October 25, 2010

Automated Install via Batch file

Below I have designed batch files for installing and uninstalling builds, the important features are the ability to run this unattended and the ability to log any issues that happen during the install.

Install.bat is a simple batch file to do a quite (/qb) install (/i) asynchronously logging all information with verbose output (/L*v). The log file will be the same name as the installer with the (Install.log) extention
Install.bat
IF EXIST %1 msiexec.exe /i %1 /qb /L*v %1.Install.log
EXIT

InstallAll.bat calls Install.bat for each MSIin the build, To make th calls synchronously (START /B /WAIT) it's import to make these calls synchronously if your installing multiple MSI's because msiexec.exe will block all subsequent calls while the first install is running.
InstallAll.bat
START /B /WAIT Install.bat MyProgramOneSetup.msi
START /B /WAIT Install.bat MyProgramTwoSetup.msi
START /B /WAIT Install.bat MyProgramThreeSetup.msi

UnInstall.bat is a simple batch file to do a quite (/qb) uninstall (/X) asynchronously logging all information with verbose output (/L*v). The log file will be the same name as the installer with the (UnInstall.log) extention
UnInstall.bat
IF EXIST %1 msiexec.exe /X %1 /qb /L*v %1.UnInstall.log
EXIT

UnInstallAll.bat calls UnInstall.bat for each MSIin the build, its good to have a way to uninstall if you don't have the option to use a virtualization platform with a snapshotting capabilities.
UnInstallAll.bat
START /B /WAIT UnInstall.bat MyProgramOneSetup.msi
START /B /WAIT UnInstall.bat MyProgramTwoSetup.msi
START /B /WAIT UnInstall.bat MyProgramThreeSetup.msi

WiX: A Developer's Guide to Windows Installer XML

Tuesday, October 12, 2010

Win 7 Phone development

Here are some screenshots from my first Windows 7 Phone application, I created it as part of "WP7 Developer Contest" Hands on lab presented by Daniel Egan at the Silicon Valley Code Camp. It was a fun time 

First screenshot is of the search page, this page is pretty simple it's hooked into the Wine.com API. The web service is called when the search button is clicked.


Second screen shot is the results I got back from the service, nothing special here just cool to see. Daniel provided the Uncorked graphic as part of the talk. At the bottom in red are the navigation buttons, the ellipsis button brings up the text for the buttons. 


I think WP7 development is easier that Win form's, This app has really got me interested in in doing WP7 development. The sample was quick and easy, I cant wait to make a real app and load it on my own Windows 7 Phone. 


Monday, August 16, 2010

Setting up SVN for Home backup

Adding Subversion SVN source control to your home server is a great hack for backing up your important files. I was using SyncBack by BrightSparks for my back ups and still do for some files, it’s very easy to use and has a lot of useful configuration options. Sometime you need an older version of a file and source control is extremely usefully in getting older versions. I wanted the ability to easily get older versions of Picture and video files and work on editing file without worrying about changing and deleting content.

Heres my quick start guide for setting up SVN for Home backup

1.       Install Subversion, I installed the CollabNet version with the default options and had no problems but you may to scan this web site first http://subversion.apache.org/packages.html and pick the one that fits you environment.
2.       Create the Repository, Create at least one repo for backing up your files
a.       Command:> svnadmin create c:\svn_repository\MyFiles
b.      I create separate repo’s for each class of files I want backups of. Like Photo, Documents, Source, Music and Video. Photo repo for all my digital photographs and a Documents repo for all my Office files and you get the rest.
3.       Next you want Verify you can connect to your repository
a.       Command:> svn list svn://localhost/MyFiles
4.       Other this you might want to do
a.       Change the password
b.      I recommend using TortoiseSVN  http://tortoisesvn.tigris.org/ it much easier than using the command line utill.


Friday, August 13, 2010

Get the content of a web page and write to file.

There’s been a couple times I wanted to keep copies of web sites to parse the data at a later date. When you don’t want to interact with the page and just need to a simple response I use the request/response methods.  This is one of the few times I don’t use html DOM automation.


This script creates a Microsoft.XmlHttp object for communicating with the web server, it does a simple get request on the Url. The same code could be used to pull down any type of content (jpg, mp3, etc..) given you have the Url.


URL = "http://www.google.com"
' Create the HTTP object
Set xmlhttp = CreateObject("Microsoft.XmlHttp")


' Open connection
xmlhttp.open "GET",  URL , false


' Send the request synchronously
xmlhttp.send ""


' Write the response to a file
Set objFileSys = CreateObject("Scripting.FileSystemObject")
Set file= objFileSys.OpenTextFile("Google.htm", 8, True, 0)
file.Write(xmlhttp.responseText)
File.Close

Wednesday, April 28, 2010

Attach debugger to NUnit GUI test runner

Here are the steps to attach Visual Studio debugger to the NUnit GUI test runner process. Attaching the debugger will allow you set breakpoints and debug NUnit test code in Visual Studio IDE.
  • Right click the Project in the solution explorer
  • Select “Start external program”
  • Right click the Project in the solution explorer
  • Click properties
  • Click the ellipses “…” button
  • Find and select the NUnit GUI test runner “c:\yourpath\nunit-x86.exe”
  • Type the name of your test dll in the “Command line arguments: “ textbox
  • Run the project and if its configured correctly the NUnit GUI runner should appear with the test dll loaded
You can also install TestDriven.NET and it packaged with NUnit and NCover, it provides right click test run and other cool stuff but can be buggy sometimes.
    I wrote this because today I ran across someone who decided to rewrite there test suite in MSTest because they couldnt debug or use break points with NUnit...  By the way, friend don't let friends use MSTest for functional tests. More than once I have run across developers or testers who didn't know how to do attach the debugger and its very simple. Perhaps the funniest occasion was on a 3 month contract with eTouch, the developers there created a separate command line (exe) project that executed the NUnit test runner passing in there dll.

    To get the Break points & Edit and Continue to work in .NET 4.0 you need to edit the nunit-x68.config file (or witch ever config of the exe your using to execute the tests)
    <startup>
        <requiredRuntime version="4.0.30319" />
    </startup>

    Thursday, January 21, 2010

    Firefox Browser Configuration for WatiN automation

    Here are some basic Firefox configuration changes I make for automation with WatiN.

    Disable all pop-up blockers

    If the pop-up blocker is enabled it will prevent new browser windows from opening.

    Steps:

    • Click “Tools”
    • Click “Options”
    • Click “Content” icon
    • Deselect “Block pop-up windows” option
    • Click “OK” button

    clip_image002

    If there are other pop-up blockers enabled you should disable them as well. Some toolbars like the Google tool bar have pop-up blockers.

    Don’t warn when closing multiple tabs

    Disable this option so the browser can be closed during automation. If this option is enabled when closing the browser window and if more than one tab is open it will cause a modal pop-up.

    Steps:

    • Click “Tools”
    • Click “Options”
    • Click “Tabs” icon
    • Deselect “Warn me when closing multiple tabs” option
    • Click “OK” button

    clip_image004

    Tuesday, January 19, 2010

    Internet Explorer Browser Configuration for WatiN automation

    Here are some basic Internet Explorer configuration changes I make for automation with WatiN.

    Do not warn if changing between secure and not secure mode

    When the protocol changes from “https” to “http” or vice-versa you are changing between secure and not secure mode. Enabling this feature will cause modal pop-ups titled “Security Alert”

    Steps:

    • Click “Tools”
    • Click “Internet Options”
    • Click “Advanced” tab
    • Look in the “Settings” section
      • Find the “Security” tree branch
        • Deselect the “Warn if changing between secure and not secure mode” option
    • Click “OK” button

    clip_image006

    “Security Alert” Pop-up:

    clip_image008

     

    Add the sites under test to the “Trusted sites” zone

    Adding the sites under test to the “Trusted sites” zone will allow you to enable zone specific security.

    Steps:

    • Click “Tools”
    • Click “Internet Options”
    • Click “Security” tab
    • Click “Trusted sites” icon
    • Click “Sites” button
    • Add all sites to be tested ….
      • o ….
    • Click “Close” button

    clip_image010

    Disable all pop-up blockers

    If the pop-up blocker is enabled it will prevent new browser windows from opening.

    Steps:

    • Click “Tools”
    • Click “Internet Options”
    • Click “Privacy” tab
    • Deselect “Turn on Pop-up Blocker” option
    • Click “OK” button

    clip_image012

    If there are other pop-up blockers enabled you should disable them as well. Some toolbars like the Google tool bar have pop-up blockers.

     

    Display mixed content

    Displaying mixed content is needed when a webpage has content that is both “http” and “https”. Not enabling mixed content will cause a modal pop-up.

    Steps:

    • Click “Tools”
    • Click “Internet Options”
    • Click “Security” tab
    • Click “Trusted sites” icon
    • Look in the “Security level for this zone” section
      • Click “Custom level...” button
    • Look in the “Settings: section
      • Find the “Miscellaneous” tree branch
        • Find the “Display mixed content” tree branch
          • Select “Enable” option
    • Click “OK” button

    clip_image014

    “Security Information” pop-up:

    clip_image016

    A real world example of this is Gmail. Gmail can be used in a secure mode over “https” so that the email is encrypted but other content is delivered over “http” such as advertisement.

     

    Check for newer versions of stored web pages

    Internet Explorer will save copies of webpages, images and other files. This will speed up browsing for the user because not all content is downloaded every time you load or refresh a page. But this can cause false positives during testing because a stored “older version” of the webpage or its content is loaded might be loaded.

    Steps:

    • Click “Tools”
    • Click “Internet Options”
    • Click “General” tab
    • Look in the “Browsing history” section
      • Click “Settings” button
    • Select the “Every time I visit the webpage” option
    • Click “OK” button

    clip_image002

    A common example of how this can cause a false positive is when an image changes name but not all references to the image are updated. If you load the webpage from a browser that has been to the page before the image is displayed correctly. If you then delete all temporary internet files and reload the page you will see a broken image link.

     

    Disable Phishing Filter

    When the Phishing Filter is enabled it can cause pop-ups

    Steps:

    • Click “Tools”
    • Click “Internet Options”
    • Click “Advanced” tab
    • Look in the “Settings” section
      • Find the “Security” tree branch
        • Find the “Phishing Filter” tree branch
          • Select “Disable Phishing Filter” option
    • Click “OK” button

    clip_image004

    Tuesday, January 5, 2010

    Pano for the iPhone

    This app kicks ass, at $1.99…

    I tried to do a 360 degree panoramic of my cubical, Pano didn't support 360’s but it did let me take a 16 picture panoramic. It did surprisingly well considering I have the smallest cube in the history of modern man ;)

    Here's a clip I snagged off there web site http://debaclesoftware.com/

    iPhone