Quantcast
Channel: Software Meadows
Viewing all 83 articles
Browse latest View live

WHS Connector Restart Error in Windows 8.0/8.1

$
0
0

After upgrading to Windows 8.1, you may find your Windows Home Server dashboard no longer works. The solution for me was:

  1. Uninstall the connector.
  2. Open a command prompt and run ipconfig /flushdns.
  3. Reinstall the connector by going to http://[WHSname]/connect.

However, in my case I would get an error “Cannot connect the computer to the server because either another software installation is in progress or, the computer has a restart pending….”

Try restarting. If that solve the problem, a registry key needs to be deleted.

http://social.microsoft.com/Forums/en-US/a90b4679-d2dc-4820-94f0-dce22da245a4/solved-cannot-install-connector-software-error-regarding-another-installation-is-in-progress?forum=whsvailbeta

Summary:

  1. Open regedit.exe.
  2. Navigate to
    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager
  3. Delete the key PendingFileRenameOperations

Lenovo U530 Touch WiFi Problem

$
0
0

I really like my U530…except that the wireless is flaky. Sometimes it will drop down to 11mbps, as if it suddenly forgot it can connect at Wireless-G speeds. Disconnecting/reconnecting fails with a “Cannot connect, forget this connection?” message. The solution has been to turn WiFi off and back on. Hardly the right thing.

I found a suggestion on a newsgroup to turn the wireless adaptor’s Roaming Aggression to “Lowest.” I tried this, but it didn’t make a significant difference. (Yes, I’m running the latest driver.)

Today, I found a setting that might do the job.

  1. Connect to the wireless network giving problems. (In my case, my home router.)
  2. Right-click the connection icon and choose “Open Network and Sharing Center.”
    image
  3. Open “Change adapter settings.
  4. Right-click the Wi-Fi adapter and choose Status.
  5. Open Wireless Properties. These are the properties for the network profile.
  6. Uncheck “Look for other wireless networks while connected to this network.”

image

I’m hoping this will stop Windows from trying to find other networks, which seems similar to the “roaming” setting (which I’ve set back to its default of “Highest.”

I’ll update this post in a week or less with whether this solved my problem.

Update 1/26/14 9:30p

And, that didn’t fix anything. So, I guess I’m still waiting on an updated driver from Lenovo, or I’ll find out if I can replace the wireless. But I’ve read that laptop hardware these days is often recorded in the BIOS, and not allowed to be changed. We’ll see.

Lenovo U530 Touch WiFi Problem Continued

$
0
0
This may not be a Lenovo and/or Intel driver issue. It might be Windows 8/8.1. I’m trying a couple of different fixes to see what sticks.

Disable Energy Management

Maybe the OS isn’t telling the adapter the right thing regarding when to shut down?
  1. Network and Sharing Center > Change adapter settings
  2. Edit your wifi adapter > Properties > Configure
  3. Choose Power Management tab and uncheck everything.
image

Disable MSI Support

I don’t know what MSI Support is, but there’s some evidence that Win8 doesn’t communicate with WiFi adapters in the same way regarding it. See Mark Hanna’s answer in this thread. https://communities.intel.com/thread/32169
[Here’s his answer copy/pasted]
Some Intel engineers did investigate this issue and this is what they found. When the system is in battery mode to save power, Windows 8 is doing something different compared to Windows 7 and earlier versions of Windows. For some reason the driver is not getting called by the OS in battery mode resulting in transmit hangs.
I do not anticipate any driver update for this issue, but you should be able to make a registry change to the interrupt type from MSI to legacy to work around the issue. After disabling MSI on a test machine here, the hang was no longer happening.
MSI can be disabled from registry. You can use Windows Device Manager to find the hardware device ID information that will be part of the path to the registry setting shown in brackets and highlightedbelow. Hardware IDs can be found in the device's "Details" tab.
Here is an example for my network connection. The numbers are different because I have a different network connection, but this does show where to find the hardware IDs.
HardwareIDs.jpg
The above information is what you will need from your network connection in order to locate the right place in the Windows registry.
Caution: Make sure you back up your registry before proceeding. Changing or deleting registry keys can have unintended consequences.
Registry Setting Path:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\PCI\[VEN_8086&DEV_XXXX&...]\3&33fd14ca&0&C8\Device Parameters\InterruptManagement\MessageSignaledInterruptProperties
Change "MSISupported" value to '0'. The value is '1' by default. You can always go back and change to '1' again if you run into any new issues.
Here is a screen shot of my registry setting that I navigated to using the hardware IDs I found in Windows device manager:
MSI.jpg

 

Update 2014-02-02

Neither of the above solved my problem. However, I finally found a forum from Intel discussing the issue, and discovered I’m not running the latest Intel drivers (I am running the latest driver on Lenovo’s site). There were several steps to deal with, but I’m install both the Bluetooth and WiFi drivers soon. I’ll check that the other changes I made aren’t in place—running default settings—and report back.
http://www.intel.com/p/en_US/support/detect

Update 2014-02-03

I don’t know yet if the latest drivers prevent the adapter from dropping down to 11mbps, but I do know the adapter got turned off while in sleep mode, and came on shortly after coming out of sleep. The power profile definitely isn’t set to do that, so I’m turning off the adapter’s Properties > Power Management > Allow the computer to turn off this device to save power.


Update 2014-02-05

The laptop hasn’t dropped to 11mbps since installing the latest drivers. I’m also letting Intel PROSet manage wireless. I just realized that of course the wireless goes to sleep while the laptop’s in sleep mode. That’s what it’s supposed to do.The import thing to me is that it properly wakes up, which it appears to be now. I have a daily backup using Windows Home Server, and the laptop is configured to wake from sleep or hibernate to perform that. Haven’t tried it in hibernate, yet!

Here’s another nugget: running System File Checker, e.g. sfc /scannow, found corrupt files it couldn’t repair. “Cannot repair member file”. I found this link that suggested running, as administrator,

dism /online /cleanup-image /restorehealth.

This indeed repaired the image, and running sfc again found no errors.

Cannot repair member file [l:36{18}]"Amd64\CNBJ2530.DPB"

sfc /scannow – Cannot repair member file

WHS 2011 Windows Update “One or more services are no running” alert

$
0
0

This is a post to myself on how to fix this problem. The symptom is continuously getting the above alert from the WHS launchpad. The solution is linked here:

http://social.microsoft.com/Forums/en-US/3f1b6cd1-d1ef-41e2-8848-eb381f8df41c/continually-receive-alert-stating-one-or-more-services-are-not-running?forum=whs2011

From user Dowlo:

I think I have resolved this now. Windows Update service was set to Automatic (Trigger Start) on the alerting machine, and Manual (Trigger Start) on my other machines. I reset it to Manual on the problem machine and the alert has not resurfaced since.

A little counter-intuitive, but there you have it.

Windows 8.1: Window Key + S = Search from Desktop

$
0
0

Something I don’t (didn’t) like about Windows 8.x is that, if you’re in the desktop, to search for an application required:

  1. Press Window key, taking you out of the desktop and into to the Modern UI.
  2. Start typing.

I hate switching contexts just to find/open an app that don’t have pinned. I mean, I can’t pin all of them! In Windows 7, this is

  1. Press Window key.
  2. Start typing.

I just discovered by exploration that in Windows 8.1 (and presumably 8.0), this sequence keeps me in the desktop:

  1. Press Window key + S.
  2. Start typing.

image

Likewise, Window key + Q, W or F. They all open the search sidebar. Note that “F” opens a file search, while the others open “search everything.”

I haven’t found a keyboard shortcut to open the Modern application list. Yet.

 

Windows 8.1 Update 1 Driver Problem DTMB BDA TV USB

$
0
0

After updating to Windows 8.1 Update 1, my wife installed a USB flash drive that previously have her no problems, and now wouldn’t show as a drive in Explorer. I got the same error on my (also updated) computer.

image

A notification was in the system tray to view devices, which showed the flash drive icon. Right-clicking that and choosing Troubleshoot suggested removing the device and reinserting. Some web searching said the same thing—which was almost right. However, the driver wasn’t being fully removed, so kept getting used again, resulting in the same error.

1

Instead, the driver needs to be completely removed. To do this:

  1. Plug in the flash drive.
  2. Open Device Manager.
  3. Find the bad device.
  4. Right-click and choose Uninstall.
  5. When prompted, check Delete the software for this device.
  6. Unplug the drive, then plug it back in.
  7. The drive should now be available.

image

4

Installing fcm flow cytrometry library on Windows 8.1

$
0
0

My friend Andrew is working with flow cytrometry, which is a fancy way of saying “a field I don’t understand.” He wanted to use a python library for analyzing data, but was having trouble getting it installed. After some effort, I found this worked. The core problem is that py-fcm hasn’t been updated to work with later versions of its dependencies. It also doesn’t list the versions of its dependent libraries, making installation difficult.

Fortunately, I happened across a site that maintains Windows binaries for lots of packages, plus a science-ready Python distribution. I don’t know if this will install properly on Windows 7, but believe it will.

Downloads

Enthought Canopy Express

This is a free Python distribution. I installed the x64 version, specifically 1.4.0-win-64, which used Python 2.7. It includes the following packages that py-fcm depends on: numpy, scipy, matplotlib, cython.

https://www.enthought.com/downloads/

DPMix

The Windows installer version of DPMix. I used version dpmix-01.win-amd64-py2.7.exe.

http://www.lfd.uci.edu/~gohlke/pythonlibs/#dpmix

Py-FCM

Download the Windows installer fcm‑0.9.1.win‑amd64‑py2.7.exe from

http://www.lfd.uci.edu/~gohlke/pythonlibs/#py-fcm

Also, download the latest source. This just makes it easier to get the sample file.

https://code.google.com/p/py-fcm/source/browse/

NOTE

I did not install mpi4py, as it is an optional dependency, but here are the links. I also didn’t install the fcm GPU support.

http://www.lfd.uci.edu/~gohlke/pythonlibs/#mpi4py

https://bitbucket.org/mpi4py/mpi4py/downloads

Installation

1. Run the Canopy installer. It does not require administrative privileges. I stuck with the defaults.

image

image

image

Clicking “Start using Canopy” will configured the environment. When configured, a window will open, which you can then close. Your desktop will have two icons, one for Canopy, the other for PyLab.

2. Run the DPMix Windows installer. It will find the Python installation and use it.

image

image

image

3. Run the py-fcm Windows installer. It likewise will find and use the Python installation.

image

4. Modify gate.py script. This is critical, as the matplotlib library no longer uses nxutils.

a) Open this file in a text editor (using your own Username for the directory): C:\Users\Charles\AppData\Local\Enthought\Canopy\User\Lib\site-packages\fcm\core\gate.py

b) Comment out line 56, and uncomment line 52.

if name is None:
name = self.name
idxs = points_in_poly(self.vert, fcm.view()[:, chan])

# matplotlib has points in poly routine in C
# no faster than our numpy version
#idxs = points_inside_poly(fcm.view()[:, chan], self.vert)


Also comment out the nxutils import on line 2


import numpy
#from matplotlib.nxutils import points_inside_poly

Test



  1. Unzip the py-fcm source. In the sample_data folder is a file named 3FITC_4PE_004.fcs.

  2. Open a text editor, and copy the complete path to the file, e.g.
    C:\Users\Charles\Documents\FCM Flow Cytometry\Py-FCM\py-fcm-91701cc7a98e\sample_data\3FITC_4PE_004.fcs

  3. Now, replace all back slashes with forward slashes.
    C:/Users/Charles/Documents/FCM Flow Cytometry/Py-FCM/3FITC_4PE_004.fcs

  4. Open PyLab from the icon on the desktop, and run the samples found here (reproduced below).

image


fcm provides the loadFCS() function to load fcs files:

>>> from fcm import loadFCS
>>> data = loadFCS('../sample_data/3FITC_4PE_004.fcs')
>>> data
3FITC_4PE_004
>>> data.channels
['FSC-H', 'SSC-H', 'FL1-H', 'FL2-H']
>>> data.shape
(94569, 4)

Since the FCMdata object returned by loadFCS() delegates to underlying numpy array, you can pass the FCMdata object to most numpy functions

>>> import numpy as np
>>> np.mean(data)
410.38791252947584
>>> np.mean(data,0)
array([ 538.76464803, 421.57733507, 340.03599488, 341.17367213])
>>> import pylab
>>> pylab.scatter(data[:,0],data[:,1], s=1, edgecolors='none')
>>> pylab.xlabel(data.channels[0])
>>> pylab.ylabel(data.channels[1])
>>> pylab.show()

_images/basic-1.png

 

References


Info about the nxutiles error. https://groups.google.com/forum/#!topic/py-fcm-dev/HibEajOCTEY


https://pythonhosted.org/fcm/install.html
https://code.google.com/p/py-fcm/
https://www.enthought.com/
http://www.scipy.org/index.html
http://matplotlib.org/
https://github.com/andrewcron/dpmix
http://docs.cython.org/src/quickstart/install.html
https://bitbucket.org/mpi4py/mpi4py/downloads
http://mpi4py.scipy.org/docs/usrman/install.html#requirements

Enable Synaptics touchpad 2-finger tap context menu

$
0
0

For some reason, my laptop’s Synaptics touchpad settings dialog doesn’t include two-finger tap to bring up a context menu (mimicking the right-click).

Having to position the mouse and physically right-click is error-prone and slower. Likewise with the included feature to two-finger click (in fact, that’s worse). It turns out the touchpad is capable of double-tap. You just have to go to the registry.

Here are the steps, mostly copied.

http://www.tomshardware.com/answers/id-1851375/finger-tap-click-windows.html

https://forums.lenovo.com/t5/Idea-Windows-based-Tablets-and/2-Finger-Tap-right-click-not-working-Win-8-0/td-p/1324087

1. To re-enable two finger tap, press Windows key + R, enter "regedit" then press enter, and on the left pane browse to the following locations:
HKEY_CURRENT_USER\Software\Synaptics\SynTP\TouchPadPS2

AND 

HKEY_CURRENT_USER\Software\Synaptics\SynTP\TouchPadSMB2c
(the first location didn't work for me, but the second location did)

2. In the right pane, double click on 2FingerTapAction and change the value to a "2" (Hexadecimal) for right click, or a "4" (Hexadecimal) for middle click

3. Double click on 2FingerTapPluginID and clear any value it may have.

4. In the right pane, find the MultiFingerTapFlags key and change it from a 2 to a 3.

4b. Additionally, if you want to enable three finger tap for middle click, double click on 3FingerTapAction and change the value to a "4", also clear any value for 3FingerTapPluginID and set 3FingerTapPluginActionID to "0".

5. Restart your PC and you can see the changes well enough.

Note that if you change any setting using the Synaptic dialog, the above will get unset and you’ll have to manually do it again.


Clever Phish

$
0
0

I received this email yesterday (links altered for safety).

From: info@gruppobertoli.it
Thanks for shopping with us today! Your purchase will be processed shortly.
BILLING DETAILS
Purchase Number: SGF578308436
Order Date: 7.46 Thu, Sep 18, 2014
Customer Email: charles@example.com
Outright Purchase: 4687 USD
Get details
Please click the link provided at the top to get more info about this issue.

Of course, I checked the domain and I'd never heard of it. But nothing came up immediately when searching "gruppo bertoli spam". I was pretty sure it was a phishing email, but it was possible someone stole my identity. Unlikely, though, given the weirdness of the email.

Next, I hovered over link to see source. It's a DropBox location. I opened IE in InPrivate Browsing mode for some added safety. Next, I copied the link and pasted into the URL. (I've obfuscated the link so it doesn't work anymore.)

https://www.dropbox.com/s/XXXXXzddrc2a4k/Order_AA9883.zip?dl=1

I removed the file part of the path, just to see if the DropBox folder would open. Nope. So, I can see they want me to download a zip file. I'm OK with that, because I won't open it yet.

I downloaded the zip file, then opened—but didn’t extract!—it using 7-zip. Huh. At first glance it's a PDF—with a funny extension. Also, the packed size is the same as the file size. But this might be true for a PDF since they’re binary files, and besides most people won't open in 7-zip, they’ll use Windows Explorer.

image

OK. I extracted the file but, of course, didn’t double click it to open.

Now, I looked at the file in Windows Explorer and it really does look like a PDF. 

image

Why? Because the clever bastards have added a bunch of spaces to hide the real extension. Here's the real file name.

"PAYMENT DETAILS.PDF                                                                                _27102.scr"

Windows (and Mac) by default don't show extensions, anyway, so many will be fooled by a file that advertises itself as a PDF. What's worse, most people don't show their file listings in Detail view, so they wouldn't see the Type, which is the giveaway.

What is it really? It's a screen saver. If I'd launched it...well, who knows? A screensaver can install trojan viruses. Hopefully my Windows Defender would have kicked in, but no guarantee.

This was a good reminder lesson to me. These jerks used the psychology of stage magic: misdirection and plausibility. It looks real, until it's not.

Prevent Word from Restoring Minimized Documents

$
0
0

This has been bugging me, and today I finally researched a solution. When using Word (and, possibly, other Office apps), if one or more documents are minimized and then a new document is opened, the minimized documents are restored. You can easily imagine how irritating this is. I’ve seen this behavior in SQL Management Studio as well.

There are two solutions (with attribution links) below, depending on your version of Word. As far as I can tell, these are independent of which Windows version is installed. Note that it’s important to update the registry keys for both docx and doc file types.

Word 2010 and later

http://answers.microsoft.com/en-us/office/forum/office_2007-word/how-do-i-prevent-word-from-redisplaying-multiple/3b7594f1-0c1e-4108-9d5f-ced532781812?page=12

(The encoded command value may differ depending on your installation.)

My registry had these settings under HKEY_CLASSES_ROOT\Word.Document.12\shell\Open\command:

Default: "C:\Program Files (x86)\Microsoft Office\Office15\WINWORD.EXE" /n "%1" /o "%u"

Command: yh1BV5!!!!!!!!!MKKSkWORDFiles>!2-1&m&8y@Nmo2r)^f-C /n "%1" /o "%u"

I changed them to this (removing the, "/o "%u"" and adding "/q" before "/n" to remove the splash screen :

Default: "C:\Program Files (x86)\Microsoft Office\Office15\WINWORD.EXE" /q /n "%1"

Command: yh1BV5!!!!!!!!!MKKSkWORDFiles>!2-1&m&8y@Nmo2r)^f-C /q /n "%1"

I did the same for HKEY_CLASSES_ROOT\Word.Document.8\shell\Open\command, and am now able to open other files without restoring or maxmizing other minimized Word .doc or .docx files.

Word 2007 and earlier

http://superuser.com/a/118967

You can fix this problem by blocking Word from using DDE to open files.

In the HKEY_CLASSES_ROOT\Word.Document.12\shell\Open key:

  • Delete or rename the ddeexec sub-key

In the HKEY_CLASSES_ROOT\Word.Document.12\shell\Open\command key:

  • Delete or rename the commandvalue (not to be confused with the command key.)
  • Edit the (Default) value and add "%1" (including quotes) at the end

[clf note: some authors recommend changing /n /dde to /q /n “%1”  I think the /q might make a difference in Win7+.]

This solves the problem for .docx files. If you also want to solve it for .doc files, do the same thing for Word.Document.8

Thanks to: Rafael's Within Windows which has detailed instructions.

How to remove Savernet (and similar) Chrome extension

$
0
0

My wife has had several incidents of extensions being installed in Google Chrome that serve up popup ads. One common installation is “savernet.” She’s a careful computer user not given to just answering “yes” to installing anything. We have a working hypothesis: at her school, she sometimes lets students log into their Chrome accounts to access documents. It’s possible those students have bad extensions, which then get installed on her computer in such a way that they load when she logs back in with her own account.

We’ve set her Chrome profile to not synchronize extensions (shown later). Here’s how I fully removed the bad extension from her home machine. There are three sections: Discovery, Removal, and Extra Info.

Discovery

Before removal, there are several places to check for the extension and its impact. But first, here’s an example of the lovely popups. My wife’s not, to my knowledge, interested in Asian beauties.

image

Opening the Extensions page via the URL Chrome://extensions will not show any previous extensions. There’ll be an oddly named one, though. Enable Developer mode to see the extension’s unique identifier, which we might need later.

image

Checking About Google Chrome, the extension also prevents auto-updating Chrome!

image

From Windows Control Panel, open Add/Remove programs, sort by date, you’ll see savernet installed.

image

I found the extension’s executable files in in c:\ProgramData, which is hidden by default. To view hidden folders:

  1. Open Windows Explorer
  2. Choose View > Options > Change folder and search options
  3. In the View tab, select “Show hidden files, folders, and drives”

image

This is what I found.

image

In Windows Explorer, with the C: drive selected, Search for *.crx. This may take a few minutes. Be sure you’re showing hidden files/folders. These are extension installation files, and it’s normal to have some. We’re looking for something out of place. For example, I once found one in C:\ProgramData\Local\Google\Drive. Any matches to the extension’s unique identifier from above? (In my case, everything was fine.)

image

Advanced Users!: Open regedit. From the keyboard, you can do this using the WIN-R keyboard shortcut and typing “regedit”. You may be prompted for Administrator privileges.

image

In regedit, select “Computer” at the top of the tree, then Edit > Find, and search for “savenet”.  You might elect to remove some keys later, but it’s not necessary since the executables will be gone.

image

Finally, in regedit, open the following key: HKEY_LOCAL_MACHINE\SOFTARE\Policies. You’ll find a Google policy. That’s what’s preventing the automatic updates.

image

Removal

  1. Uninstall the Savernet application.
    image
  2. Delete the C:\ProgramData\Savernet folder (and any other bad ones).
  3. Uninstall the Chrome extension.
    image
  4. Close Chrome using CTRL-Q or from the menu. DON’T just click the window’s “x”.
    image
  5. Open Control Panel > Internet Options and, ideally, reset all. If you use IE a lot, this may be a problem. I don’t know how to just uninstall an IE addin. If you use Firefox, you need to remove the extension in that browser, too.
    imageimage
  6. Delete the Policies\Google registry key. Be careful! Only select the “Google” key, then press delete. Selecting/deleting the wrong thing can cause serious problems!
  7. Advanced: I found an entry for “savernet” in HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Session Manager\PendingFileRenameOperations, which I deleted.
    image
    image
  8. Reopen Chrome. Open About Google Chrome page. If asked to update, go ahead.
  9. Advanced: If desired, delete savernet-related registry keys.
  10. Empty your Windows Recycle Bin, just to be on the safe side.

Here’s the Extensions page after clean up, showing the expected extensions.

image

Extra Info

Don’t Sync Extensions

You can prevent Chrome from synchronizing certain items. Open Chrome Settings > Advanced sync settings and uncheck as desired.

image

Incognito Mode

This might help my wife stay safe, and yet allow her students to retrieve work in an emergency. To open Chrome in Incognito mode, which prevents loading extensions:

If pinned to the task bar, right-click and choose Open New Incognito Window

image

Otherwise, Win-R to open run dialog, and enter:

C:\Program Files (x86)\Google\Chrome\Application\chrome.exe --incognito

image

The little spy guy shows you’re incognito.

image

Removing Unremovable Bluetooth Device: FAIL!

$
0
0

This is a “notes” post, no nice graphics and probably typos. If it helps you—or you sympathize—then it was worth posting.

In June of 2013 I bought an Acer Aspire R7-571. It looked great, and worked pretty well except for two things: the spacebar didn’t always respond, and the wireless seemed slow and flaky.

I shipped it in for repair on the spacebar, which was successful. For some reason, I didn’t ask about the WiFi. About six months later, I gave it to my wife and bought a Lenovo IdeaPad U530 Touch. Which also had WiFi problems. Those got straightened out, eventually, by using Intel drivers. But it took about a year.

Recently, I had to do a bare metal restore of the R7. After the restore, the WiFi problem was strongly evident: flaky performance and seemingly throttled speeds at 5GHz. After some research, I decided to replace the adaptor with a dual band Intel 7260 + Bluetooth. The replacement took about twenty minutes, and the WiFi came right up.

But no Bluetooth. Apparently (more research), the R7’s hardware doesn’t work equally with all wireless cards, which I frankly find bizarre and absurd. But, there was nothing for it except to put the old card back in and plan on selling the machine when I could (with full disclosure to prospective buyers, of course). I really should have removed the Bluetooth keyboard and mouse before starting any of this….

After the card was reinstalled, I could see the keyboard/mouse listed in Bluetooth, but the hardware wouldn’t respond. I tried deleting them. No good. I tried repairing. The “new” devices wouldn’t show. I tried deleting three different ways (see below). No good. What follows is the rest of the story (sorry, Paul Harvey).

Here are the symptoms. Some people refer to these as “ghosted” devices.

Searched file system for “sculpt”, took about 30 minutes. nothing found.

Searched registry, nothing found.

Being held in memory? Even after removing from registry and uninstalling driver?

In the following steps, unless indicated, neither mouse nor keyboard were on.

  1. Closed all bluetooth-related apps.
  2. Deleted registry entries.
  3. Uninstalled Broadcom bluetooth software. (Nothing to do if using native drivers?)
  4. Restart as directed.
  5. Checked for “sculpt” in registry and files.
  6. Items appeared in registry. Deleted keys and uninstalled Bluetooth USB module driver from Device Manager.
  7. Reboot.
  8. Research “sculpt”. Nothing in registry or file system.
  9. Found “missing” bluetooth in Devce Manager, tried updating driver, nothing.
  10. Ran Windows Update to see if standard drivers would appear. No updates.
  11. Installed Bluetooth drivers. Devices showed up in Device Manager again! How???
  12. OK, uninstall BT software and drivers again, and this time delete the WIDCOMM folder in Program Files.
  13. Search for WIDCOMM in registry and files. Delete all occurrences (where appropriate). Clear Recycle Bin.
  14. Restart.
  15. Set the devmgr_show_nonpresent_device=1 environment variable. Nothing new in Device Manager.
  16. Reinstall Bluetooth software.
  17. And, there they are again! Seems impossible. But, fine, restart.
  18. Tried an earlier BT driver version.
  19. Enabled Administrator user and logged in as that user. Same results.

Tried lots of other suggestions from various sites. None worked. I can’t believe this, but I’m going to have to do a clean reset/reinstallation.

What I can’t fathom is where the device information is being stored. The display names have to come from somewhere, and if they aren’t in the registry or file system, where else can they be? Nowhere is the right answer, but apparently the incorrect one.

You win, Acer. You’ve succeeded in guaranteeing I won’t buy another item from you. I said this once before, and then you lulled me with your siren song. But no more. The wax is firmly in my ears.

Better Google Sites Design–The Notched Page

$
0
0

I am not a web designer. Lest that be unclear, let me call it out.

I am not a web designer

But, I can imitate, and I can figure things out. Except programmable thermostats. Baffling.

It’s no secret that Google Sites themes are uniformly mediocre. I went searching for tutorials on how to do better, and found some help—not much—and a company, Kirksville Web Design, who specializes in them. This was a pretty big help, because I got to look at actual sites that I knew could be done in GS. I could either pay them for templates, or figure it out.

This isn’t a tutorial on how to use Google Sites, nor on how to create web images. I’m assuming you know enough about both. (I use Inkscape to create a lot of my graphics.)

Now, if you want a really professional site, hire a professional designer like Kirksville. But if you want a decent looking site, here are instructions for creating a simple, better design. The reference web site—again, designed by Kirksville—is Aim for ‘A’. The basic layout features a notched design.

Notched Site Design Layout

That’s not so attractive, but the final site I created is.

image

Initial Setup

Create a Google Site (GS) with a blank template and the Blank Slate theme. You’ll get a pretty ugly page.

image

Edit the page and add some text.

image

Now we’re ready to edit the Site Layout

Site Layout

  1. Only activate Header and Horizontal Navigation (deactivate Sidebar). Set Site Width to Custom 1000px (press Enter in this text box to save the setting).
  2. Click the Header to edit, and set height to 130px. This is what gives the upper notched effect. Less height increases the notch.
    image
  3. Click the Close button. This gives us a centered site.

image

Now, choose Manage Site.

Manage Site

In the General page,

  1. Uncheck Show Site Name at Top of Pages
  2. Click Configure Search. Uncheck “Enable Search.” This gets rid of the search box.
  3. Under Mobile: Check Automatically Adjust Site to Mobile Phones
  4. Save

Now open the Themes, Colors, and Fonts page. For the header and footer, you’ll need the following. I used png files, but you could use jpg or gif as desired.

  • A single-color image 1px wide by 200px high, named header-background.png. I chose color #646464.
  • A single-color image 1px wide by 100px high, named footer-background.png.I chose color #646464.
  • A header/logo image 1000px wide by 130px high, named header.png. I made the image’s background color #646464 to match the header color. A more advanced (and better) technique is to surround the logo/text with a transparent box only as big as needed, to save download size.

Make these changes.

  1. Entire Page
    1. Background color: #c8c8c8.
    2. Image: header-background.png. Repeating horizontally fills the space without downloading a large file.
      image
    3. Wrapper: footer-background.png. Note Vertical Position is “bottom.”
      image
  2. Site header
    1. Background Image: header.png. No repetition. (see More about Headers, below).
      image
  3. Content area
    1. Background color: white
  4. Save.

Et voila!

image

There’s clearly more that should be done to make this attractive, but this gives you a good start.

More About Headers

The Hudson CMA web site has a centered logo. I didn’t use a 130x1000 image for this. Instead, I surrounded the logo in a transparent box to give the margins I wanted. Then, instead of adding the logo using Manage Site > Themes, I added it using Site Layout > Header.

image

One isn’t necessarily better than the other, though they can lead to differences in how the horizontal menu is placed. More on that in another post.

References

Google Sites: Build Your Own Theme

Summit Stuff: Designing Google Sites

GSites Gallery   Great inspiration

Google Sites Web Design  A site maintained by Kirksville

Site Template  If you want to buy templates

Kirksville Web Design

Encrypting app.config

$
0
0
Developers often use the app.config (or web.config) file to hold database connection strings and application settings. For example:
<connectionStrings>
<add name="WonderDb" connectionString="Server=BigServe1;Database=Wonder;Integrated Security=True" providerName="System.Data.SqlClient" />
</connectionStrings>
<appSettings>
<add key="FtpUser" value="ariadne" />
<add key="FtpPassword" value="maze1$" />
</appSettings>

You can find several pages on how to encrypt these settings, but they don’t usually show a typical solution, which, for me, includes:
  1. Encrypting/decrypting both connectionStrings and appSettings in one step.
  2. Doing it from code.
  3. Reduced parameters.
Granted, this is a simple case, where I don’t care about selectively encrypting settings. For that, Jon Galloway has a good post. In fact, we’ll use Jon’s post as our basis.

Important: In your project, you need to add the System.Configuration assembly. You also add using System.Configuration, but that by itself doesn’t include all the methods we need without referencing the assembly.

In my version, I removed the check for whether the section is locked, because I want an error thrown.
if (!section.ElementInformation.IsLocked)
{. . .
}

I also allow either encrypting or decrypting. Finally, I wrap up the default behavior, encrypting both appSettings and connectionStrings, in a single method call. Here’s the complete Console Application code.
using System;
using System.Configuration;

namespace EncryptConfig
{
class Program
{
static void Main(string[] args)
{
SetDefaultConfigEncryption(true);
Console.ReadLine(); //check the file, see if it’s encrypted.
}

private static void SetDefaultConfigEncryption(bool encrypt)
{
SetConfigSectionEncryption(encrypt,"appSettings");
SetConfigSectionEncryption(encrypt, "connectionStrings");
}

private static void SetConfigSectionEncryption(bool encrypt, string sectionKey)
{
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
ConfigurationSection section = config.GetSection(sectionKey);
if (section != null)
{
if (encrypt && !section.SectionInformation.IsProtected)
{
section.SectionInformation.ProtectSection("DataProtectionConfigurationProvider");
}
if (!encrypt && section.SectionInformation.IsProtected)
{
section.SectionInformation.UnprotectSection();
}
section.SectionInformation.ForceSave = true;
config.Save(ConfigurationSaveMode.Full);
}
}
}
}

Assuming an executable named EncryptConfig.exe, when running the above in Debug mode, the file that’s encrypted is bin\Debug\EncryptConfig.vshost.exe.Config

That’s nice and makes sense, because that’s the executable that’s actually in use, even though the regular exe has been built, too.The vshost config file is immediately reverted back when debugging ends. Here’s the encrypted version. Whew!
<connectionStrings configProtectionProvider="DataProtectionConfigurationProvider">
<EncryptedData>
<CipherData>
<CipherValue>AQAAANCMnd8BFdERjHoAwE/Cl+sBAAAAtX6m55SoIUyvHb37ZhfgAAQAAAACAAAAAAAQZgAAAAEAACAAAAAkgsqGn6mo3noCKO2peA8w799u8ajWVLado9goQ8esSAAAAAAOgAAAAAIAACAAAADqB7GDKmDFY9buAJlgMDyUoos81ALB/3/UKAtk3wT53TADAAAHixr6r15/5eNFgPHnXPJD950sY5F9oAjYRF4Cpfu9sfd532WpEOxFnST1W4LgX+u+d8so2rf5FqN3ikxsJY4Y1p3xpQeJEA1xa4i9L4n5arPabK4mmNn7fKTKjxri1Xktqkhkb1FLV/opfFFRnOlRy64nFOzWr4Ucwwsr8VR7d3TTt6MD2Bg3pJDZiUgjcQ+tXdD8cHkEhfKfxbMdeLfO65uG6VbyAm+ldjp7p9D6c2Z9DyBbq+rEShrMvMTL+lZ52j9H63sD+V93ESJ9FMgjOMX48TG2ZvboQE6EbiLmM0uH50BqziGUat3ft3Frc+0mQHfoqhnVs2M7mCt5mkjE3Tb0pcvjN3XvWVqo9wy5jxB0K/9yRuPTtSdVBV1q4chHGUZ4XsvBjTnt67LP2XdAYcu/Xju6Swv/dkgXMuXPzuAMgizX86CYuLebR0hMNH3Spiz9ODX98wUFCJMzJ4kQupxpdRNafNKISQWZI7119Anjehz4x3yeWJjUNoatTMWxoQ2xeYr+SlyiRoTOI3BrvfPGgpkDG9nQH2S+8dWMJyWRPHBs2GbrPqjjtLA1yR+2rqt9Uocv29oBJ6DwvnT+FA0p9P/Qp91jzEpRmcTEz+EYoIJfwSsBOIZuRXllcNJkaO1Ni/ThvGpTg0aqotXrhY0MoQlI4m/iPly2qkKVKr3O1qMwY9GrYERTrbj5pKb+hXFPgsOAEDgRBiAHsH6FuoZjG0MIXVTGg4zmJ+7rhsa8EPh61ROI6DwW1rRTA9DSKs9LS1sxeHTR/8QWaLxZuRWSwjuZJaVybPyllU1rvOFzDY9Nv96wk1n9u6s21fSf233l4nuu+7np8VfUdYUxNGfn0TwH69bh8cg1wqaJVCEoSioMHFidrKArtSCciJHW27jn3/SsRz4HWNudebTY8WZTf9YsLTuP0jC7dxuX9CIpuhcJBXitpvyVGxwC5NfmKDAsl/Dws4Rt+/YXVJ/4j5JvT35ZxYbTm/cZgvhL/z6j5odkCkIxey3ulqt1o57VNWJ18Ks0lTStRN0esejDVL6ThnqSVtlP2BCB5bThoRGXvyxhuz6Y/ON4SgeK8vBAAAAAX9I6BKGWYUcUHSscMRV2a6VGisOj9FzqTTWn0YAbeQ2hK0ZuYgK2x7hgp6iZcFJnvvuvXWTHzdvDtEliixpHQQ==</CipherValue>
</CipherData>
</EncryptedData>
</connectionStrings>
<appSettings configProtectionProvider="DataProtectionConfigurationProvider">
<EncryptedData>
<CipherData>
<CipherValue>AQAAANCMnd8BFdERjHoAwE/Cl+sBAAAAtX6m55SoIUyvHb37ZhfgAAQAAAACAAAAAAAQZgAAAAEAACAAAAAcT/dxC/l5+9h0pizxo4Thn6rgtJlRVLwGediRA8DpywAAAAAOgAAAAAIAACAAAADHdhTfi7lUXxm6CwB3S252W+lo63eEXsNwxrnPOdfQUCABAACM0LuV5c69abxGbAY6Btx9i/lUhfqjGd8B5MvNCmkwN9hQW90sPzgwBYc7o7EJPM9M2PrgbMXmCo1fUn45ZZdoL68b9andNZe78AJAKz+HNRPBaW3UD2ruwZMKr8F/FVlFxrVnrgytRxDbNNZGfwOR8WrfLsISJdOJHjZcOhLU+hsSVeA2WeSPoH/QR7L+zGqZ15/9VmULHK/0J2KacFKyqn8d4SNIOehAR+t7tlec/qdSsFYtsIWq+c4k4mgWWOVwhCXqzc+3dXRforeEYuBHfsG5KyYsxsaZZdg2dm3wooCJCCv8tK86FuDCBym8L5R1oreRWT8WAq73UM4GJn5in5ZDeAK00lnhjB8DddOy7GjrflIIM63Rc1ClXUrfm3lAAAAA+KiFbW8vRL7rF6Kl9uKDpVp8uzCMs5JcPM9lqHz5XNNQ3m7zEk8TaVoOLC56AKu5rJ+ecX76XYWfQqvpQxDj/g==</CipherValue>
</CipherData>
</EncryptedData>
</appSettings>

There’s nothing new here, I just wanted to document what I think of as a common implementation instead of the generic one. If I’ve made a security error let me know.

References

Many pages reference David Hayden’s seminal post on the subject, but I was unable to locate the original.

https://msdn.microsoft.com/en-us/library/ms254494(v=vs.110).aspx
Jon Galloway’s Post
4 Guys from Rolla

More Encrypted Config Files–ClickOnce Complications

$
0
0

Prologue

In my previous post, I detailed a solution for encrypting sections of the app.config (the technique is similar in a web app). Since then, I ran into some issues in a Windows Form application I was developing.
  • I needed to encrypt email SMTP data.
  • Initially, I’d get an error when trying to access the smtp section.
  • When published as ClickOnce, the application threw an error and wouldn’t open.

Act I

Let’s create a simple app. First, a Windows Form app with three labels. All the code will be in the same page as the Form1 class, to keep things simple.
image

Add connectionString, appSettings and smtp sections to the app.config.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<connectionStrings>
<add name="MashDb"
connectionString="Server=.\SQLExpress2012;Database=MASH;Trusted Connection=True;"
providerName="System.Data.SqlClient"/>
</connectionStrings>
<appSettings>
<add key="Password" value="4077"/>
</appSettings>
<system.net>
<mailSettings>
<smtp deliveryMethod="Network" from="pierce@mash.net">
<network
host="ohmyseoul.kr"
port="25"
defaultCredentials="true"/>
</smtp>
</mailSettings>
</system.net>
</configuration>


Add reference to System.Configuration to the project.

image


The static Settings class, to get the app.config data. This is personal preference; I know you can also use the Settings designer for this, but it’s kind of hidden and finicky.
public static class Settings
{
public static string MashDb { get { return ConfigurationManager.ConnectionStrings["MashDb"].Name; } }
public static string Password { get { return ConfigurationManager.AppSettings["Password"]; } }
}


The static ConfigSettings classes. (Or whatever you’d name your general security utilities.) This is different than what I showed previously. Specifically, they don’t optionally take an executable name. Instead, they take the full path to a config file, essential to solving the ClickOnce problem.
public static class ConfigSettings
{

/// <summary>
/// Encrypts/decrypts the connectionStrings, appSettings and smtp sections.
/// </summary>
/// <param name="encryption"></param>
/// <param name="configPath">Full path to config file</param>
/// <remarks>https://msdn.microsoft.com/en-us/library/ms254494(v=vs.110).aspx</remarks>
public static void SetDefaultConfigEncryption(bool encryption, string configPath = null)
{
SetConfigSectionEncryption(encryption, "appSettings", configPath);
SetConfigSectionEncryption(encryption, "connectionStrings", configPath);
SetConfigSectionEncryption(encryption, "system.net/mailSettings/smtp", configPath);
}

/// <summary>
/// Encrypts/decrypts the connectionStrings, appSettings and smtp sections.
/// </summary>
/// <param name="encryption"></param>
/// <param name="sectionName"></param>
/// <param name="configPath">Full path to config file</param>
/// <remarks></remarks>
public static void SetConfigSectionEncryption(bool encryption, string sectionName, string configPath = null)
{
//if no configPath supplied, get the currently executing exe's config.
if (string.IsNullOrWhiteSpace(configPath))
{
configPath = Assembly.GetEntryAssembly().Location + ".config";
#if (DEBUG)
AppDomain domain = System.AppDomain.CurrentDomain;
configPath = Path.Combine(domain.SetupInformation.ApplicationBase, domain.FriendlyName + ".config");
#endif
}

try
{
//Open the configuration file and retrieve the connectionStrings section.
ExeConfigurationFileMap fileMap = new ExeConfigurationFileMap();
fileMap.ExeConfigFilename = configPath;
Configuration config = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None);
ConfigurationSection section = config.GetSection(sectionName);
if (section == null)
{
return;
}
// Encrypt the section.
if (encryption)
{
if (!section.SectionInformation.IsProtected)
{
section.SectionInformation.ForceSave = true;
section.SectionInformation.ProtectSection("DataProtectionConfigurationProvider");
}
}
// Remove encryption.
if (!encryption)
{
if (section.SectionInformation.IsProtected)
{
section.SectionInformation.UnprotectSection();
}
}
// Save the current configuration.
config.Save();
}
catch (Exception ex)
{
throw new Exception("Unable to encrypt. " + ex.GetBaseException().Message);
}
}
}


In the Form1 class, add the form Load event, and also the method for encrypting the config. You might be tempted to use System.AppDomain.CurrentDomain.FriendlyName, but in a ClickOnce application this will return “DefaultDomain,” and no site I’ve seen has an answer why.

public partial class Form1 : Form
{
public Form1()
{
EncryptClickOnceConfig();
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
label1.Text = Settings.MashDb;
label2.Text = Settings.Password;
label3.Text = new System.Net.Mail.SmtpClient().Host;
}

private void EncryptClickOnceConfig()
{
//Encrypt config. This didn't work properly in Load. Would lead to error "Unrecognized attribute ‘configProtectionProvider’
//after encrypting app.config when reading smtp
//Weird stuff for ClickOnce Deployment.
//https://social.msdn.microsoft.com/Forums/windows/en-US/3d7ba97f-684c-46a2-9f7b-5d17e989baa8/encrypting-connection-string-with-clickonce-deployment?forum=winformssetup
//ClickOnce writes two config files for some reason.
{
if (ApplicationDeployment.IsNetworkDeployed && ApplicationDeployment.CurrentDeployment.IsFirstRun)
{
//GetPaths
string exeFile = Assembly.GetEntryAssembly().Location;
//get directory above the executable's.
string parentPath = Path.GetDirectoryName(Path.GetDirectoryName(exeFile));
string configName = Path.GetFileName(exeFile) + ".config";
//get the matching files
foreach (string configFile in Directory.GetDirectories(parentPath, "*" + configName, SearchOption.AllDirectories))
{
ConfigSettings.SetDefaultConfigEncryption(true, configFile);
}
}
else
{
//good for debugging, sets the vshost config
ConfigSettings.SetDefaultConfigEncryption(true);
}
}
}
}

Act II

Publish the application. This will automatically create a self-signed certificate. (In a follow up post, I’ll document (for my easy reference) how to create a certificate that lasts more than a year.) There are two important things to do here:
  • Set the project to Release.  This is critical. It should be obvious, but it’s easy to forget and leads to one of the errors.
  • It’s important to install it from a network location, which you can fake by sharing your publish folder and using the UNC path to it. I published to the solution folder. Give the share full permissions (for testing only).

image



You should also enable automatic updating.

image



Install from the UNC path. The app should open.

image



With the app open, open Task Manager, right-click the app, and choose “open file location.”

image



The folder will contain a EncryptedConfigClickOnceSample.exe.config file, which should be encrypted. But you’ll also find another folder, a sibling above or below the one you’re in, also with a EncryptedConfigClickOnceSample.exe.config, which should also be encrypted.

So, fine, it works. How were the problems fixed?

Act III

Encrypt the SMTP Info

This one’s pretty easy. Pass the SetConfigSectionEncryption() method the string “system.net/mailSettings/smtp”. What I found interesting is that you can’t submit just “system.net”, or “system.net/mailSettings” Apparently, in some  Orwellian programming community, some sections are more equal than others.

Error Accessing the SMTP Info

Set the program to Debug mode and republish. Run the app, letting it self-update. You should receive an error
Unrecognized attribute 'configProtectionProvider'

image

Some sites say to call ConfigurationManager.RefreshSection, but the problem really seems to be the behavior when in Debug mode. The error seems to be caused by how configuration info is accessed after the application starts. It’s not clear to me, and no web page mentioned debug mode. But it worked.

ClickOnce Error

In one application, when I tried to install it simply wouldn’t open. I believe this was also due to publishing in Debug mode. However, I also moved my call to configure the config file from Form_Load to the constructor. In my testing app, that’s not making any difference.

Epilogue

Encrypting the app.config could be critical for certain organizations where the highest security is preferred, even if the risk is very low.

References

http://stackoverflow.com/questions/7856951/unrecognized-attribute-configprotectionprovider-after-encrypting-app-config

https://social.msdn.microsoft.com/Forums/windows/en-US/3d7ba97f-684c-46a2-9f7b-5d17e989baa8/encrypting-connection-string-with-clickonce-deployment?forum=winformssetup

Source Code

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

using System.Net.Mail;
using System.Configuration;
using System.IO;
using System.Deployment.Application;
using System.Reflection;

namespace EncryptedConfigClickOnceSample
{
public partial class Form1 : Form
{
public Form1()
{
EncryptClickOnceConfig();
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
label1.Text = Settings.MashDb;
label2.Text = Settings.Password;
label3.Text = new System.Net.Mail.SmtpClient().Host;
}

private void EncryptClickOnceConfig()
{
//Encrypt config. This didn't work properly in Load. Would lead to error "Unrecognized attribute ‘configProtectionProvider’
//after encrypting app.config when reading smtp
//Weird stuff for ClickOnce Deployment.
//https://social.msdn.microsoft.com/Forums/windows/en-US/3d7ba97f-684c-46a2-9f7b-5d17e989baa8/encrypting-connection-string-with-clickonce-deployment?forum=winformssetup
//ClickOnce writes two config files for some reason.
{
if (ApplicationDeployment.IsNetworkDeployed && ApplicationDeployment.CurrentDeployment.IsFirstRun)
{
//GetPaths
string exeFile = Assembly.GetEntryAssembly().Location;
//get directory above the executable's.
string parentPath = Path.GetDirectoryName(Path.GetDirectoryName(exeFile));
string configName = Path.GetFileName(exeFile) + ".config";
//get the matching files
foreach (string configFile in Directory.GetFiles(parentPath, "*" + configName, SearchOption.AllDirectories))
{
ConfigSettings.SetDefaultConfigEncryption(true, configFile);
}

}
else
{
#if (DEBUG)
//good for debugging, sets the vshost config
ConfigSettings.SetDefaultConfigEncryption(true);
#endif
}
}
}
}

public static class Settings
{
public static string MashDb { get { return ConfigurationManager.ConnectionStrings["MashDb"].Name; } }
public static string Password { get { return ConfigurationManager.AppSettings["Password"]; } }
}


public static class ConfigSettings
{

/// <summary>
/// Encrypts/decrypts the connectionStrings, appSettings and smtp sections.
/// </summary>
/// <param name="encryption"></param>
/// <param name="configPath">Full path to config file</param>
/// <remarks>https://msdn.microsoft.com/en-us/library/ms254494(v=vs.110).aspx</remarks>
public static void SetDefaultConfigEncryption(bool encryption, string configPath = null)
{
SetConfigSectionEncryption(encryption, "appSettings", configPath);
SetConfigSectionEncryption(encryption, "connectionStrings", configPath);
SetConfigSectionEncryption(encryption, "system.net/mailSettings/smtp", configPath);
}

/// <summary>
/// Encrypts/decrypts the connectionStrings, appSettings and smtp sections.
/// </summary>
/// <param name="encryption"></param>
/// <param name="sectionName"></param>
/// <param name="configPath">Full path to config file</param>
/// <remarks></remarks>
public static void SetConfigSectionEncryption(bool encryption, string sectionName, string configPath = null)
{
//if no configPath supplied, get the currently executing exe's config.
if (string.IsNullOrWhiteSpace(configPath))
{
configPath = Assembly.GetEntryAssembly().Location + ".config";
#if (DEBUG)
AppDomain domain = System.AppDomain.CurrentDomain;
configPath = Path.Combine(domain.SetupInformation.ApplicationBase, domain.FriendlyName + ".config");
#endif
}

try
{
//Open the configuration file and retrieve the connectionStrings section.
ExeConfigurationFileMap fileMap = new ExeConfigurationFileMap();
fileMap.ExeConfigFilename = configPath;
Configuration config = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None);
ConfigurationSection section = config.GetSection(sectionName);
if (section == null)
{
return;
}
// Encrypt the section.
if (encryption)
{
if (!section.SectionInformation.IsProtected)
{
section.SectionInformation.ForceSave = true;
section.SectionInformation.ProtectSection("DataProtectionConfigurationProvider");
}
}
// Remove encryption.
if (!encryption)
{
if (section.SectionInformation.IsProtected)
{
section.SectionInformation.UnprotectSection();
}
}
// Save the current configuration.
config.Save();
}
catch (Exception ex)
{
throw new Exception("Unable to encrypt. " + ex.GetBaseException().Message);
}
}
}
}

Creating a Long-Lasting ClickOnce Certificate

$
0
0
This post’s for me, since I’ve occasionally had to look this up.

Here are the two command lines of code needed to create a long-lasting, untrusted ClickOnce certificate. You run this using the Visual Studio command prompt. I recommend putting the certificate info in a separate folder, documenting the procedure and passwords, and storing in version control. The purpose isn’t deep security, it’s letting the apps install and run with minimal fuss.
C:\MakeCertDemo> makecert -sv MyClickOnce.pvk -n "CN=MY ClickOnce" MyClickOnce.cer -b 08/01/2015 -e 12/31/2100 -r
C:\MakeCertDemo> pvk2pfx -pvk MyClickOnce.pvk -spc MyClickOnce.cer -pfx MyClickOnce.pfx -po X0PASS!

The –r switch is required to ensure the certificate’s length is greater that 1024 bits, otherwise Windows will refuse the ClickOnce installation. Older articles about using MakeCert omit that.

The development certificate created by Visual Studio when publishing a ClickOnce application lasts just a year. You can get with your network admin to create a domain-level certificate for internal publishing, if you have Windows Enterprise Server. Or buy a Verisign certificate for trusted public publishing. But often, small businesses just need to publish internal apps with little fanfare. The app developers need:
  1. A long-lasting certificate
  2. To not discover they don’t know the original certificate password (“Hey, who wrote this? Know password? OK, I’ll create a new certificate.”)
  3. Consistency

References

Certificate Expiration in ClickOnce Deployment

Stack Overflow

DigitallyCreated

The Google Photos Management Problem(s)

$
0
0

The Executive Summary (you can pretend you’re an exec)

  • Storing photos in one place with one compelling interface is good. I wish Google had that.
  • Google Photos is bad.
  • Pictures on Google Drive is non-obvious.
  • Blogger integration with pictures is non-obvious.
  • I should be more careful.
  • Picasa is still required to make my blog go.
  • Google Photos is bad.
It’s not a mistake that I listed one item twice.

The Setup

Google strives, mostly successfully, to keep their applications simple. Simple to understand, simple to use, simple to explain. Google also wants us to store our millions of pictures with them, because they are a gateway to marketing, and thus advertising.

I have a blog, the very one you’re reading. It’s hosted on Blogger, which is owned by Google. I often use screen shots, a.k.a pictures, like this one.
Dewy grass sm
And, I use Windows Live Writer to compose my posts, because it has easy copy/paste of pictures, good formatting control, and useful plugins. (It’s also quite old and unmaintained, so here’s hoping Scott Hanselman is successful getting Microsoft to release it as open source, because I think WLW would rapidly improve.)

When I publish using WLW, the screen shots end up in a Google . . . somewhere. When I finish composing a blog post, WLW opens the post in my preferred browser, which is Google Chrome. It all looks hunky dory, and I’m pleased with my writing prowess, which I know is what chicks would dig if I weren’t a relatively old man.

The Story

So the other day I proudly opened my post about encrypting app.config in Microsoft’s new Edge browser (in Windows 10), and—what’s this? No images? Just gray boxes with a circle-dash icon?
image
Well, this new browser certainly does suck daikon. Good thing the pictures show in Internet Explorer, right? Nope. Same problem. But they look great in Chrome. Must be Windows 10. Or Windows Live Writer, which led me on an odyssey of reading about how Google “broke” blogging apps by requiring better authentication, and giving something like two years’ notice. Maybe that’s the problem? No, it isn’t, that got fixed fairly quickly.

Then it must be Windows 10. Somehow this got past the thousands of people testing the app for a year (as if). I’ll check in lovely Windows 7 from work.

Same thing. Only now, I don’t see pictures in Chrome, either. Which is the clue to the solution. Because at work, I hadn’t logged into my Google account before viewing my blog.

Ah ha. Maybe, somehow, the pictures aren’t public. And I never noticed, because I always viewed the blog while logged in. Bad on me for not testing other browsers. (I did test other browsers, though, in the past. I guess I unwittingly changed the permission.)

OK, I’ll just check the album and set it for public, like I would if it were in Google Drive. Now . . . where is it?

Google Photos? I’ve been hearing about that. It's the app on my phone I don't like. Yeah, there it is! All I have to do is . . . is . . . huh? This is your new, improved photo collecting and organizing application Mr Brin? This. Is. Bad.
  • Initial view is all your pictures, sorted descending by date, in every size imaginable (doubled, in my case, because of how WLW works).
  • Choose the Collections view and you get what, exactly? What’s a collection? It looks like an album. So why’s it called a collection? Oh, it’s because a collection could be photos, movies or stories (whatever those are). And a collection of photos is called—I’m perfectly serious—an album. While a collection of movies is called “Movies.”
    image
  • You can’t create an empty album. You have to create an album from existing pictures you’ve already uploaded. From that massive, date-sorted ocean you saw earlier. Which is the exact opposite of how a sane person creates an album. We, the people, create an album and then upload pictures from our phone or computer to that album. We at least want that option!
  • You can’t change the sharing of an album, as far as public/private is concerned. You can share to Google+, Facebook or Twitter, or get a shareable link.
More reading. I dimly recall Google is storing lots more stuff on Drive. Are they storing photos? Why, yes!
image

Excitedly, I click the link and, indeed, I see my photos. Some of them. And some are different from what’s in Photos, despite the icon and text telling me I’m looking at, um, Photos. No albums. Too bad, because it looks like I can make individual photos publically accessible here. This is an illusion though, as far as my blog is concerned. The settings aren’t related. So this is useless. Gamely, I check the settings, and indeed there’s an intriguing option.
image

But I don’t check it. It doesn’t feel right. Why would I need to connect Google Photos to Google Drive in order to access sharing properties on Google Albums that are, somehow, already set? And I’m nervous that, according to some descriptions, I can make changes in Drive that affect Photos, but not the other way around. Or is it the reverse?

The Solution

Wait . . . hang on. Isn’t Photos a new application? Weren’t we storing photos before? With some other program that I tried? (snap, snap, snap) Picasa. That’s it. Didn’t Picasa have albums? Is it possible? . . . Yes. Follow the trail.
image
image
image
image

Save and done. Now all of my blog pictures are visible again. That was easy.
image

The Problems

Did you keep count? Google has four places you can manage your pictures:
  1. photos.google.com, the new kid, where G wants us to end up.
  2. Google Photos accessible from Google Drive.
  3. Pictures in a folder in Google Drive, somehow connected to Google Photos.
  4. Pictures in Picasa.
It’s a mess. I’m sad.

ShoreTel - Brilliantly Simple?

Auto Updating a New Windows 7 Installation

$
0
0

There are many reasons you may create a clean Windows installation:

  • Gold image for deployment
  • Lab installation for testing
  • Reinstall/recovery

Installing all the Windows updates is tedious, especially with reboots. I don’t know why Microsoft doesn’t include a big “Bring up to date” button that would let you configure for reboots. I figured someone had this sorted, and started searching.

I can’t take credit for the PowerShell script, but am glad to have found it. It does have one oddity: it attempts to disable OpenSSHd. I don’t know if that’s a weird security leftover, or a precaution by the author. The script still runs even if the OpenSSHd service isn’t found, which it shouldn’t be. It’s not part of Windows.

I made these changes:

  1. Commented out OpenSSH commands
  2. After searching for updates, I selectively hide updates such as KB3035583, which is the Windows 10 advertisement (not needed in my case).

Here’s the link to the original script by Joe Fitzgerald:

https://gist.github.com/joefitzgerald/8203265

And the script itself, with my changes. To execute the script, right-click and choose Run with PowerShell. Or

  1. open admin command prompt
  2. cd to location of script file
  3. > powershell.exe -ExecutionPolicy ByPass -File win-update.ps1

 

param($global:RestartRequired=0,
$global:MoreUpdates=0,
$global:MaxCycles=10)

function Check-ContinueRestartOrEnd() {
$RegistryKey = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Run"
$RegistryEntry = "InstallWindowsUpdates"
switch ($global:RestartRequired) {
0 {
$prop = (Get-ItemProperty $RegistryKey).$RegistryEntry
if ($prop) {
Write-Host "Restart Registry Entry Exists - Removing It"
Remove-ItemProperty -Path $RegistryKey -Name $RegistryEntry -ErrorAction SilentlyContinue
}

Write-Host "No Restart Required"
Check-WindowsUpdates

if (($global:MoreUpdates -eq 1) -and ($script:Cycles -le $global:MaxCycles)) {
Stop-Service $script:ServiceName -Force
Set-Service -Name $script:ServiceName -StartupType Disabled -Status Stopped
Install-WindowsUpdates
} elseif ($script:Cycles -gt $global:MaxCycles) {
Write-Host "Exceeded Cycle Count - Stopping"
} else {
Write-Host "Done Installing Windows Updates"
Set-Service -Name $script:ServiceName -StartupType Automatic -Status Running
}
}
1 {
$prop = (Get-ItemProperty $RegistryKey).$RegistryEntry
if (-not $prop) {
Write-Host "Restart Registry Entry Does Not Exist - Creating It"
Set-ItemProperty -Path $RegistryKey -Name $RegistryEntry -Value "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File $($script:ScriptPath)"
} else {
Write-Host "Restart Registry Entry Exists Already"
}

Write-Host "Restart Required - Restarting..."
Restart-Computer
}
default {
Write-Host "Unsure If A Restart Is Required"
break
}
}
}

function Install-WindowsUpdates() {
$script:Cycles++
Write-Host 'Evaluating Available Updates:'
$UpdatesToDownload = New-Object -ComObject 'Microsoft.Update.UpdateColl'
foreach ($Update in $SearchResult.Updates) {
if (($Update -ne $null) -and (!$Update.IsDownloaded)) {
[bool]$addThisUpdate = $false
if ($Update.InstallationBehavior.CanRequestUserInput) {
Write-Host "SKIPPING: $($Update.Title) because it requires user input"
} else {
if (!($Update.EulaAccepted)) {
Write-Host "> Note: $($Update.Title) has a license agreement that must be accepted. Accepting the license."
$Update.AcceptEula()
[bool]$addThisUpdate = $true
} else {
[bool]$addThisUpdate = $true
}
}

if ([bool]$addThisUpdate) {
Write-Host "Adding: $($Update.Title)"
$UpdatesToDownload.Add($Update) |Out-Null
}
}
}

if ($UpdatesToDownload.Count -eq 0) {
Write-Host "No Updates To Download..."
} else {
Write-Host 'Downloading Updates...'
$Downloader = $UpdateSession.CreateUpdateDownloader()
$Downloader.Updates = $UpdatesToDownload
$Downloader.Download()
}

$UpdatesToInstall = New-Object -ComObject 'Microsoft.Update.UpdateColl'
[bool]$rebootMayBeRequired = $false
Write-Host 'The following updates are downloaded and ready to be installed:'
foreach ($Update in $SearchResult.Updates) {
if ($Update.IsDownloaded) {
Write-Host "> $($Update.Title)"
$UpdatesToInstall.Add($Update) |Out-Null

if ($Update.InstallationBehavior.RebootBehavior -gt 0){
[bool]$rebootMayBeRequired = $true
}
}
}

if ($UpdatesToInstall.Count -eq 0) {
Write-Host 'No updates available to install. Press any key.'
$global:MoreUpdates=0
$global:RestartRequired=0
#wait for user input, so message is seen
$wait = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
break
}

if ($rebootMayBeRequired) {
Write-Host 'These updates may require a reboot'
$global:RestartRequired=1
}

Write-Host 'Installing updates...'

$Installer = $script:UpdateSession.CreateUpdateInstaller()
$Installer.Updates = $UpdatesToInstall
$InstallationResult = $Installer.Install()

Write-Host "Installation Result: $($InstallationResult.ResultCode)"
Write-Host "Reboot Required: $($InstallationResult.RebootRequired)"
Write-Host 'Listing of updates installed and individual installation results:'
if ($InstallationResult.RebootRequired) {
$global:RestartRequired=1
} else {
$global:RestartRequired=0
}

for($i=0; $i -lt $UpdatesToInstall.Count; $i++) {
New-Object -TypeName PSObject -Property @{
Title = $UpdatesToInstall.Item($i).Title
Result = $InstallationResult.GetUpdateResult($i).ResultCode
}
}

Check-ContinueRestartOrEnd
}

function Check-WindowsUpdates() {
Write-Host "Checking For Windows Updates"
$Username = $env:USERDOMAIN + "\" + $env:USERNAME

New-EventLog -Source $ScriptName -LogName 'Windows Powershell' -ErrorAction SilentlyContinue

$Message = "Script: " + $ScriptPath + "`nScript User: " + $Username + "`nStarted: " + (Get-Date).toString()

Write-EventLog -LogName 'Windows Powershell' -Source $ScriptName -EventID "104" -EntryType "Information" -Message $Message
Write-Host $Message

$script:UpdateSearcher = $script:UpdateSession.CreateUpdateSearcher()
$script:SearchResult = $script:UpdateSearcher.Search("IsInstalled=0 and Type='Software' and IsHidden=0")
if ($SearchResult.Updates.Count -ne 0) {
$script:SearchResult.Updates |Select-Object -Property Title, Description, SupportUrl, UninstallationNotes, RebootRequired, EulaAccepted |Format-List
$global:MoreUpdates=1
} else {
Write-Host 'There are no applicable updates'
$global:RestartRequired=0
$global:MoreUpdates=0
}

#clf hide undesired updates
foreach ($Update in $SearchResult.Updates) {
if ($Update.Title.Contains("KB3035583")) {
Write-Host "Hiding $($Update.Title) because it's the Windows 10 Notification."
$Update.IsHidden = $TRUE
}
}
}

$script:ScriptName = $MyInvocation.MyCommand.ToString()
$script:ScriptPath = $MyInvocation.MyCommand.Path
$script:UpdateSession = New-Object -ComObject 'Microsoft.Update.Session'
$script:UpdateSession.ClientApplicationID = 'Packer Windows Update Installer'
$script:UpdateSearcher = $script:UpdateSession.CreateUpdateSearcher()
$script:SearchResult = New-Object -ComObject 'Microsoft.Update.UpdateColl'
$script:Cycles = 0

# $script:ServiceName = "OpenSSHd"

# Stop-Service $script:ServiceName -Force
# Set-Service -Name $script:ServiceName -StartupType Disabled -Status Stopped

Check-WindowsUpdates
if ($global:MoreUpdates -eq 1) {
Install-WindowsUpdates
} else {
Check-ContinueRestartOrEnd
}

 

References

An alternative method, clever but not as flexible.

http://serverfault.com/questions/320750/best-way-to-fully-update-a-new-installed-windows

WSUS Update class

https://msdn.microsoft.com/en-us/library/windows/desktop/aa386099(v=vs.85).aspx

Powershell ReadKey doesn’t work when using editor.

https://social.technet.microsoft.com/Forums/windowsserver/en-US/0787bcba-f977-400d-8b62-57ec64a71a8a/why-do-i-get-an-exception-calling-readkey?forum=winserverpowershell

Recover VirtualBox Snapshots

$
0
0

I had something kind of awful happen last night. I was taking VirtualBox on an mSATA USB storage drive between work and home to do lab testing. I had upgraded VBox at work, but not at home, and made the mistake starting my VM at home before upgrading. Running VMs on two different machines is tenuous, but I didn’t expect to suddenly be faced with my VM unable to boot.

I found that the .vbox file was bad. Most of the snapshot and hard disk elements were missing. I had all the snapshots themselves, but nothing to say how to use them. I was able to get the VM back to booting, but it was to my first snapshot, meaning I’d lost hours of work.

After many false starts, I managed this solution, got myself to my last state, and was able to clone the VM. I didn’t end up with a set of snapshots, but did have the last state of the VM, which mattered the most.

This isn’t a tutorial; it presumes you understand VirtualBox, editing XML, etc. Sorry, but it was more important for me to get this out of my head quickly.

Order of Snapshots

I needed to know the order of my snapshot chain. I didn’t have multiple nests, just one chain, which was lucky. But some of my false starts changed the modified file datetime, so I suddenly couldn’t rely on that (I know, “make a backup, fool!”)

(Note: VMDK? Yes, I was using VMware disks in VBox, since ultimately the VM is going into VMware. I don’t think that made any difference, but will use native VDI in the future, then convert the resulting disk to VMDK if needed.)

HxD Hex Editor to the rescue! Snapshot disks are huge, like 35GB, and I needed to peer into them because parent-child info is stored there. Most text editors load the file into memory—very bad for large files. Disk-based editing was the only way. I could have used the excellent UltraEdit, but just needed to see text. HxD loaded the files instantly (literally), and the information I needed was at the top, better viewed bytes/row = 128

# Disk DescriptorFile.version=1.CID=b5058026.parentCID=ffffffff.createType="monolithicSparse"..# Extent description.RW 83886080 SPARSE "Win7ProGold.vmdk"..# The disk Data Base .#DDB..ddb.virtualHWVersion = "4".ddb.adapterType="ide".ddb.uuid.image="3b111bc1-9b1e-4b4c-ad00-f4f4a09d7d43".ddb.uuid.parent="00000000-0000-0000-0000-000000000000".ddb.uuid.modification="b042f5da-7fa4-4f1f-a0a1-6820d032819b".ddb.uuid.parentmodification="00000000-0000-0000-0000-000000000000".ddb.geometry.cylinders="16383".ddb.geometry.heads="16".ddb.geometry.sectors="63".ddb.geometry.biosCylinders="1024".ddb.geometry.biosHeads="255".ddb.geometry.biosSectors="63"

I made a list of the snapshot UUIDs and their uuid.parent IDs, et voila!

{bf1e79c5-69f0-49d6-ae11-05fd4d4e6e5d}.vmdk UUID  parent 3b111bc1-9b1e-4b4c-ad00-f4f4a09d7d43
{558ea477-39bd-40c6-953b-2c3c8b961668}.vmdk UUID parent bf1e79c5-69f0-49d6-ae11-05fd4d4e6e5d
{35dd8ad4-47d0-4033-823f-dbbc8f367d9a}.vmdk UUID parent 558ea477-39bd-40c6-953b-2c3c8b961668
{81ce7961-fa37-46ef-8ae0-a8461e5ebe1b}.vmdk UUID parent 35dd8ad4-47d0-4033-823f-dbbc8f367d9a
{0197c2be-2ae3-4599-938d-fcf013b77abb}.vmdk UUID parent 81ce7961-fa37-46ef-8ae0-a8461e5ebe1b
{2b790ec1-be3a-4a7b-8075-89bc54948825}.vmdk UUID parent 0197c2be-2ae3-4599-938d-fcf013b77abb

.vbox File

Now, how to update the .vbox file. Without going into the sordid tale…

  1. Remove snapshot info from <Machine> element.
  2. Remove top <Snapshot> element.
  3. Add nested <HardDisk> elements in the correct order.
  4. Set the StorageController <Image> uuid to the last hard disk element’s uuid.

Yuck

<machine laststatechange="2016-02-02T12:16:14Z" snapshotfolder="Snapshots" ostype="Windows7_64" name="Win7ProGold" uuid="{e21fa63b-d412-4e19-88c8-971ec7bc3ad7}">
    <mediaregistry>
      <harddisks>
        <harddisk uuid="{3b111bc1-9b1e-4b4c-ad00-f4f4a09d7d43}" type="Normal" format="VMDK" location="Win7ProGold.vmdk">
          <harddisk uuid="{bf1e79c5-69f0-49d6-ae11-05fd4d4e6e5d}" format="VMDK" location="Snapshots/{bf1e79c5-69f0-49d6-ae11-05fd4d4e6e5d}.vmdk">
            <harddisk uuid="{558ea477-39bd-40c6-953b-2c3c8b961668}" format="VMDK" location="Snapshots/{558ea477-39bd-40c6-953b-2c3c8b961668}.vmdk">
              <harddisk uuid="{35dd8ad4-47d0-4033-823f-dbbc8f367d9a}" format="VMDK" location="Snapshots/{35dd8ad4-47d0-4033-823f-dbbc8f367d9a}.vmdk">
                <harddisk uuid="{81ce7961-fa37-46ef-8ae0-a8461e5ebe1b}" format="VMDK" location="Snapshots/{81ce7961-fa37-46ef-8ae0-a8461e5ebe1b}.vmdk">
                  <harddisk uuid="{0197c2be-2ae3-4599-938d-fcf013b77abb}" format="VMDK" location="Snapshots/{0197c2be-2ae3-4599-938d-fcf013b77abb}.vmdk">
                    <harddisk uuid="{2b790ec1-be3a-4a7b-8075-89bc54948825}" format="VMDK" location="Snapshots/{2b790ec1-be3a-4a7b-8075-89bc54948825}.vmdk" />
                  </harddisk>
                </harddisk>
              </harddisk>
            </harddisk>
          </harddisk>
        </harddisk>
      </harddisks>

<StorageControllers>
  <StorageController name="SATA" type="AHCI" PortCount="2" useHostIOCache="false" Bootable="true" IDE0MasterEmulationPort="0" IDE0SlaveEmulationPort="1" IDE1MasterEmulationPort="2" IDE1SlaveEmulationPort="3">
    <AttachedDevice type="HardDisk" hotpluggable="false" port="0" device="0">
      <Image uuid="{2b790ec1-be3a-4a7b-8075-89bc54948825}"/>
    </AttachedDevice>


At this point, I could start the VM successfully and clone it, flattening the disk structure.

Viewing all 83 articles
Browse latest View live




Latest Images