Tuesday, June 4, 2013

Enable F12 in Internet Explorer for Dell iDRAC

By default, pressing the F12 key in Internet Explorer displays the developer tools bar at the bottom of the Internet Explorer window. If the user is an administrator who needs to access the Integrated Dell Remote Access Controller (iDRAC) to work with physical servers, this can be a problem as the BIOS on the servers is configured to use F12 to select boot options during power-up. In Internet Explorer, pressing F12 displays the Developer Tools bar instead of the server’s boot options.

This can be corrected on an individual PC basis by setting the following registry key for any user who needs access to the iDRAC:

HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\IEDevTools\Disabled

This key should be created as a DWORD with the value of 1.

To block the Developer Tools for all users on a PC, the following keys can be set:

[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Internet Explorer\IEDevTools]
"Disabled"=-

[HKEY_CURRENT_USER\Software\Policies\Microsoft\Internet Explorer\IEDevTools]
"Disabled"=dword:00000001

Note that these keys can be set on a per-user basis, configured in the default system image, or pushed out through Group Policy preferences, set by a script, etc. – whatever makes sense in your organization.

Tuesday, January 29, 2013

How to Fix iPod Touch Update Errors

While updating my fourth-generation iPod Touch to iOS 6.1, I encountered a problem. The iTunes software generated an error that prevented the update from happening. The iPod was left in the “Connect to iTunes” mode.

I tried restarting the PC and reconnecting the iPod, but iTunes still did not recognize it.  After a number of false starts, I finally managed to get it updated and restored.

The following instructions are based on those found in multiple pages on Apple’s web site:

  • Disconnect the iPod Touch’s USB cable.
  • Hold down the home button and the power button until either the “power off” slider appears or the iPod turns itself off.
  • Hold down the home button while plugging the USB cable back into the iPod. It should now power back on and go into the same “Connect to iTunes” display. 




  • Several seconds later, iTunes will indicate that it sees the device: 




  • Click OK.
  • Back in iTunes you’ll see a button labeled “Restore iPod”. 


 
(Your iTunes window might look a little different from this, or contain a different date. That is OK.)

  • Click the “Restore iPod..” button.
  • iTunes will begin attempting to update the iPod to the current iOS version and restore the backup to it. If you’re lucky, this will be the end of it and your iPod will be back to normal. If so, stop here. If your iPod still didn’t restore, continue to the next step.  (In my case, I got an "unknown error" code.)
  • Verify that your iTunes software is the most current version. On Windows, launch the Apple Software Update software to see if an update is available. If so, install it. On Mac OS X, use Software Update.  (This was not the issue I had.)
  • On Windows, make sure you have the latest Windows Updates installed. Use the Windows Update control panel or the Windows Update web site.  (This also was not my issue.)
  • Disconnect all the USB devices from the computer except for the keyboard, mouse, and iPod. Try Restoring the iPod again. If this works, reconnect all the devices.  (This allowed the process to get further on my system, but it still received an error code 9.)
  • Temporarily disable your antivirus software and try restoring the iPod again. Some antivirus software can conflict with iTunes updating the iPod.  (Did not help in my case.)
  • Temporarily disable your firewall software and try the update again. Firewall software can in some cases prevent the update. (Did not help in my case.)
  • If you’re getting an error message during synchronization, look up that error number here: http://support.apple.com/kb/TS3694
    The above page provides detailed descriptions and troubleshooting steps for many different error numbers reported by iTunes.

My answer turned out to be a variation on the last bullet above.  The third-party cable I was using to do the synchronization was apparently dropping its connection to the PC every so often causing the update and restore to fail.  Swapping the USB cable out with an Apple-manufactured one solved my issue (probably in combination with disconnecting all non-essential USB devices).

References

The following pages provided information used to produce this article.


Sunday, December 2, 2012

VBScript: Delete a Folder if it’s Empty

It is unfortunately common that software installers will leave behind an empty folder when they are finished.  If you want to keep your system clean, you’ll need to add code to your deployment script to remove a folder from the PC if the folder is empty.

The following subroutine will, when passed the path to a folder (e.g., “C:\Test1\Test2”) will delete that folder (in the example, “Test2” but not “Test1”) if that folder is empty (i.e., contains no other files or folders).

For example, let’s say you have the following files and folders on a PC:

    • D:\Temp\Test\
    • D:\Temp\Test2\
    • D:\Temp\Test2\myfile.txt
    • D:\Temp\Test3\subfolder\

If you execute the following lines of code:

DeleteFolderIfEmpty(“D:\Temp\Test”)

DeleteFolderIfEmpty(“D:\Temp\Test2”)

DeleteFolderIfEmpty(“D:\Temp\Test3”)

The following things will happen:

  • Since there are no files under the D:\Temp\Test directory, the Test directory will be deleted.
  • Since there is a file (myfile.txt) under D:\Temp\Test2, that directory will not be deleted.
  • Since there is a subfolder under D:\Temp\Test3, that directory will not be deleted.

Feel free to use this code as you see fit.

Sub DeleteFolderIfEmpty(folderPath)

    Dim theFso, theFolder
    set theFso = CreateObject("Scripting.FileSystemObject")
   
    If thefso.folderExists(folderPath)=False Then
       Wscript.echo "Folder '" & folderPath & "' does not exist."
       Exit Sub
    End If
   
    Set theFolder = thefso.getfolder(folderPath)
   
    If thefolder.files.count > 0 Then
       Wscript.echo "Folder contains " & theFolder.files.count & " file(s)."
       Exit Sub
    Else
       Wscript.echo "Folder contains no files."
    End If
   
    If theFolder.subfolders.count > 0 Then
       Wscript.echo "Folder contains " & theFolder.subfolders.count & _
                   
" subfolder(s)."
       Exit Sub
    Else
       Wscript.echo "Folder contains no subfolders."
    End if
   
    Set theFolder = Nothing
    Wscript.echo "Deleting: " & folderPath
    thefso.DeleteFolder folderPath,True

End Sub

Thursday, September 27, 2012

Problem-Solving Methodologies

In Karl Albrecht’s book Brain Building: Easy Games to Develop Your Problem-Solving Skills, the author suggests that there are seven techniques used by most problem-solvers.  It’s worth noting these and thinking about them when you’re faced with a complicated or difficult problem to solve:
  1. Stepping:  Break a complex or lengthy issue into individual steps, rather than trying to tackle it all at once. 
  2. Picturing:  Drawing a picture, diagram, flowchart, or similar sketch that helps you understand the problem and identify options.
  3. Rephrasing:  State the problem in a different way, using different words or phrases.  Sometimes this can trigger ideas that weren’t obvious before.
  4. Fencing:  Put a figurative “fence” around the problem by making certain assumptions, filtering out irrelevant conclusions, or otherwise reducing the scale of the problem. 
  5. Itemizing:  List the options, possibilities, potential causes, available tools, etc. 
  6. Chaining:  Order the options into a chain or sequence, by some quality that makes sense, such as impact on users, time to implement, potential to break something else, etc.
  7. Jumping the Track:  Approach the problem from a new angle.  Reconsider options you ruled out, re-test your assumptions, or otherwise try to make some kind of creative leap.
These problem-solving methodologies can be helpful to Windows desktop administrators in their daily lives.  Imagine that you had one of these problems:
  • A virus has made its way into your network and is spreading from machine to machine.  You can’t solve this in one action, so you employ stepping.  You start by preventing further spread by identifying the network ports it’s using and blocking those at the router or desktop firewall.  Then, you begin identifying the infected machines and work on cleaning them up.  Next, you update your antivirus software to detect the malware and prevent further infection.  Finally, you reactivate the ports in the routers or firewalls.
  • You arrive at the office to find that no one can login to their PCs.  You start by itemizing the possible causes.  Maybe it’s a patch applied to the PCs. Maybe it’s a network issue. Maybe the domain controller is having trouble.  Then, you start fencing the issue, ruling out the patch because it’s unlikely that every PC received the patch.  Since there are some networked devices working, you fence out the network.  (It could still actually be the patch or network, but you rule these out initially to reduce the scope of things you’re looking at.)  When you find that the domain controller is OK, you quickly construct a diagram of the components of the login process.  You then begin stepping through those components one at a time, looking for the problem.
The odds are good that you’ve used these methodologies before without thinking about it.  However, keeping the list handy can be useful at times when you find yourself “stuck” solving a problem.  You may have tried a couple of the methodologies without success.  Looking at the list, you may realize that you haven’t tried rephrasing the problem or drawing a diagram.

Friday, September 21, 2012

Windows PowerShell Resources

If you do Windows PowerShell scripting, or are trying to learn to do it, you may find the following references of value:

Monday, September 3, 2012

VBScript to Determine if a DLL is Registered

In a VBScript, you may want to delete files from the target PC.  If one of those files is a DLL, deleting it could cause applications to stop functioning.  It can be helpful to know, before deleting a DLL, if it’s still registered with Windows.  The following VBScript code, when provided with the name of a DLL file, will determine if that DLL has been registered with Windows.

To use the function in your script, call it as in the following example:

xyz = isDllRegistered(“abc.dll”)

When the above line of code is executed the variable “xyz” will contain the value True if the DLL named “abc.dll” is registered, or False if it is not.

function isDllRegistered(theDLL)

   set theShell = CreateObject("WScript.Shell")
   set Catalog = CreateObject("COMAdmin.COMAdminCatalog")
   isRegistered = false
 
   ' Get the Applications collection and populate it.
   set Applications = Catalog.GetCollection("InprocServers")
   Applications.Populate()

   ' Loop through the collection and output info
   For Each AppObject In Applications

     theName = appobject.name
     theID = appobject.key

     on error resume next
     thePath = theshell.RegRead("HKCR\CLSID\" & theID & "\InProcServer32\")
     if err.number <> 0 then
        thePath = "<UNKNOWN: " & theID & ">"
        if theName <> "" then thePath = theName
        err.clear
     end if
     on error goto 0

     thePath = theShell.ExpandEnvironmentStrings(thePath)

     if instr(1,lcase(thepath),searchForDll)>0 then
        isdllRegistered = true
     else
        isdllregistered = false
     end if

  
   Next
End Function

Sunday, May 27, 2012

Invoking an ActiveSetup Script via VBScript

During software deployment, and at other times, it can be helpful to run a script or command the next time a user logs into the PC.  The Active Setup feature of Windows uses a registry key to trigger an action to take place once for each user, during that user's login. 

If, for example, you wanted to ensure that certain files were copied into each user's profile when they next login, you could use Active Setup to do that.  The subroutine below, when supplied with the right information, will create the appropriate registry key to trigger the specified script, program, or command the run on each user's next login on this PC.

The syntax of this subroutine is:

SetActiveSetup productName, versionNumber, commandToRun

Where:

  • productName is a string that represents the product being installed, or is any kind of unique identifier for the task being executed.
  • versionNumber is a string that represents the version of the task being run.  If a task has already been executed for a specific product and version for a specific user, it will not run again.  Changing this version number will cause the task to run again.
  • commandToRun is the exact command that should be run on each user's next login on this PC.  It can be as simple as "cmd /c del c:\temp\log.txt" (delete the file log.txt in the C:\temp directory) or as complex as pointing to a VBScript to run.

Note that the "commandToRun" will be run as the user logging into the system.  If the user has limited permissions (i.e., is not a power user or administrator) the command will be unable to do anything requiring elevated permissions. 

The best way to familiarize yourself with ActiveSetup is to work with this script on a virtual PC.  Reset the PC to a "clean" snapshot.  Configure the script to run the desired command. Run the script. Log off the VM, and log on.  Verify that the command ran as expected. If not, reset the VM and try again.

Sub SetActiveSetup (strProductName,strVersionNumber,strCommandToRun)
    Dim HKEY_LOCAL_MACHINE: HKEY_LOCAL_MACHINE = &H80000002
    Dim HKEY_CURRENT_USER : HKEY_CURRENT_USER = &H80000001
    Dim strKeyPath, strValue, strValueName, strFolder, oReg
   
    If IsNull(strProductname) Then
       WScript.echo "Null product name passed to SetActiveSetup. Aborting."
       WScript.Quit 13
    End If
   
    If IsNull(strCommandToRun) Then
       WScript.echo "Null strCommandToRun passed to SetActiveSetup. Aborting."
       WScript.Quit 13
    End If
   
    If strProductName = "" Then
       WScript.echo "Blank product name supplied to SetActiveSetup. Aborting."
       WScript.Quit 13
    End If
   
    If strCommandToRun = "" Then
       WScript.echo "Blank strCommandToRun supplied to SetActiveSetup. Aborting."
       WScript.Quit 13
    End If   
   
    If IsNull(strVersionNumber) Then
       WScript.echo "Null strVersionNumber supplied, setting to 1.0."
       strVersionNumber = "1.0"
    End If
   
    Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
          
    strKeyPath = "SOFTWARE\Microsoft\Active Setup\Installed Components\" & strProductName
    oReg.CreateKey HKEY_LOCAL_MACHINE, strKeyPath
        
    strValue = strCommandToRun
    strValueName = "StubPath"
    oReg.SetStringValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, strValue
   
    strValueName = "Version"
    oReg.SetStringValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, strVersionNumber
   
    strValue = "SUITE.VBS"
    strValueName = "ComponentID"
    oReg.SetStringValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, strValue
End Sub