• Simple vbscript (HTA) to install fonts via SCCM

    We have a group of users that need the ability to install fonts (.ttf and .otf). They are not administrators for their machines, so we usually go down there and install the fonts using runas. Since advertised SCCM programs can run as system, I can write a script to copy the fonts into the fonts directory. If I mark the package as allow user to intereact and run as administrator, the script will pop for the user to pick the fonts they want to install. Here is my hta code that runs once a button is clicked:

    	Set objShell = CreateObject("Shell.Application")
    	Set objFolder = objShell.BrowseForFolder (0, "Install Fonts From (Source):", (0))
    	If objFolder Is Nothing Then
    		window.close
    	Else
    		Set objFolderItem = objFolder.Self
    		objPath = objFolderItem.Path
    	End If
    
    	Set objFso = CreateObject("Scripting.FileSystemObject")
    	Set objFolder = objFso.GetFolder(objPath)
    	bolGotFonts = False
    	For each objFile in objFolder.Files
    		If objFolder.Files.Count > 0 Then
    		  If lcase(objFso.GetExtensionName(objFile.Path))="ttf" OR lcase(objFso.GetExtensionName(objFile.Path))="otf" then
    			bolGotFonts = True
    			DataArea.InnerHTML = DataArea.InnerHTML & "<input type=""checkbox"" name=""" & objFile.Path & """>" & objFile.Path & "</input><br/>"
    		  End if
    		End If
    	Next
    	if bolGotFonts Then DataArea.InnerHTML = DataArea.InnerHTML & "<br/><input id=runbutton  class=""button"" type=""button"" value=""Install Font"" name=""run_button""
    

    This code will popup a browse dialog and put the filenames found in the select directory into the HTA’s DataArea.innerHTML (DataArea is just a <div>) with a checkbox and button to initiate the copy of the files:

    SUB InstallFont
        DIM colChkElem, strDriveName, objChkBox
        SET colChkElem = window.document.getElementsByTagName("input")
        FOR EACH objChkBox IN colChkElem
            IF objChkBox.Type = "checkbox" THEN
                IF objChkBox.checked THEN
                    strFileName = objChkBox.name
                    Set objShell = CreateObject("Shell.Application")
                    Set objFolder = objShell.Namespace(FONTS)
                    objFolder.CopyHere strFileName
                END IF
            END IF
        NEXT
        DataArea.InnerHTML = ""
    END SUB
    

    Seems to work!


  • I am a CTT+ !!!!

    Just got my results from the performance based evaluation. Passed!!!! I am now a CompTIA Certified Technical Trainer (CTT+).


  • Unix diff in PowerShell

    Compare-Object (Get-Content .\file1.txt | Sort-Object) (Get-Content .\file2.txt | Sort-Object)
    

  • I am a Microsoft Certified Trainer (MCT)!!!


  • Hide a field in a SharePoint edit form based on other values

    We have a form (list) that we want to have everyone edit and give comments. Once everyone has edited the item, we want an “overall status” field to trigger a workflow (send extended email). Be we did not want the overall status to be changed until everyone has chimed in. To achieve this, we created a list and there was a dropdown with everyone’s name to Approve the item. The default of the dropdown was “Pending”. I used the jquery below to hide the “overall status” until there were no dropdowns that said “Pending”

    $('select :selected').each(function(){
    if($(this).text() == "Pending") {
    $('tr:has(input[title=Overall Status])').not('tr:has(tr)').hide();
    };
    });
    

    The hide code is code that Paul Galvin published here.
    jquery is cool.


  • Why did apple call their chat software in iOS4 face time?

    Why not iChat? Will it work with iChat? I really don’t understand the difference.


  • How to make a field in a SharePoint Edit form readonly

    Paul Galvin showed how to hide a field in a SharePoint. I wanted to use this code to make a field “read only” once a from has been submitted. Forgetting about DataSheet view (for now), we can put a Content Editor Webpart on the top of the EditFrom.aspx page (to add a CEWP to the top of the edit from, append the URL to this -> EditForm.aspx?ToolPaneView=2) and include his code:

    $('tr:has(input[title=Disclaimer])').not('tr:has(tr)').hide();
    

    This will hide the filed based on the Column Name (Disclaimer). Taking this a step further, we can get the selected value (a drop down box in this case), and append a column after the hidden column with some formatting, a column name and the selected value. Effectively making the column readonly.

    <script type="text/javascript">
    $(document).ready(function(){
    $('tr:has(select[title=Disclaimer])').not('tr:has(tr)').hide();
    $('tr:has(select[title=Disclaimer])').not('tr:has(tr)').append( '<tr><td nowrap="true" valign="top" width="190px" class="ms-formlabel"><H3 class="ms-standardheader">Disclaimer Accepted:</H3></TD><td valign="top" class="ms-formbody" width="400px">'+$('select[title=Disclaimer] :selected').text()+'</td></tr>');
    });
    </script>
    

  • I have to say I was excited about the Balmer at Macworld rumor.

    If I could use C# and compile for the Mac? That a would be sweet. I would sit down and formally learn C#!