MacGyvering Windows 8.1 Remote Assistance

My Mother called me up rather frazzled this evening.

This isn’t too surprising. Since her stroke 16 years ago she can sometimes become confused or forget simple things, things she once knew.

Tonight, the cause of her frazzled state was her computer.

After listening to her rant and ramble about her computer, I quickly realized that she had some web browser pop-up phishing telling her she had a virus. Partly because of who she is, and partly because of brain damage from stroke, she called the phone number that the pop-up displayed. When they told her they can fix it for $199 and if she took it to Best Buy, they would charge her $350-$400, this fueled her worry.

After some calming I finally had her start the Windows Remote Assistance application, but unfortunately she has forgotten what saving files actually means and she has no email configured. So she is unable to save the remote assist file and she can’t use Windows Remote Assistance to automatically email the request to me. It was at this point that I suggested she mail the laptop to me. I also may have said, “never again!” when I agree to support a laptop that someone else gifted her.

But, I couldn’t let it go. This was a challenge and I love a challenge.

I searched around a bit and tried my hand at the msra.exe command line. After a bit of trial and error, I realized I can have her open a powershell and type

msra /saveasfile helpme 12345678

Yes, I’m ok with the 12345678 password in this case. Trying some other password over the phone and having her type it was error prone.

“Did you say bee?”

“No I said pee, like Paul.”

“Bee like ball?”

“No…”

I still needed a way to get a file to me. I’ve had an aversion to PowerShell ever since it launched, despite tech reviewing a very fine PowerShell book. I knew it was probably my best bet at getting a file to me. After a bit of poking I found the invoke-webrequest helper, thingy. I don’t know PowerShell terminology. It looks like a function to me.

I have my home server on the internet. Its running Ubuntu Linux  and I’ve had 4 line php upload scripts with html forms that let people send me files for years. Could I use this?

The shoelace was there. The paperclip was there. Did I also have some bubble gum?

All I really needed as an index.php in a /mom/ directory that looked like this:

<?php
file_put_contents('err.out', file_get_contents('php://input'));
?>

Wow that is some trivial stuff. Bland bubble gum, I guess.

Why an index.php and a /mom/? Well, because that will be easy for me to relay over the telephone.

I did some testing and found invoke-webrequest works nicely coupled with this http request body dumping php.

invoke-webrequest -uri jrwren.xmtp/mom/ -infile .\helpme
.msrcincident -method post

I was able to call my mom back, tell her, to press windows key-r, reminding her that windows key is usually between the ctrl and alt on the keyboard, and to type powershell and press enter.

“Powershell, P-O-W-E-R-S-H-E-L-L- no spaces?”

“Yup”

On first try, I tried to have her use the password 1234, but msra.exe complained that it was too short. Working through this mistake, I tried to have her use the up arrow to edit the previously executed command line in powershell.

“What is the up arrow?”

This honestly dumbfounded me and I had absolutely no idea what to do for a minute or so.

“The up arrow on my keyboard is on the right. There is an inverted tee of arrows, left right up down to the left of my left control key.”

Whew, I got lucky and she found it.

Once we had the msra.exe create the helpme file, I had her type out the invoke-webrequest command, prompting her to press tab after typing helpme to autocomplete the file extension.

The multiline color output of running the command shocked and surprised her. It maybe even scared her a little bit, but as she was reading it aloud, I heard her say, “200 OK”

“200 OK is great”, I said.

I checked my server and there was an err.out file along side the index.php. The only two files in the mom directory.

My home server always has samba setup. I used Windows Explorer to navigate to H:\public_html\mom and I renamed err.out to helpme.msrcincident. I double clicked it.

Mom said, “Oh what is this? jrwren wants to share your computer.”

I rejoiced inside.

The hard part being done, I was able to connect and control her computer. Microsoft has done a very nice job with Windows Remote Assist, ever since Windows 7. I’m impressed that my Windows 7 can connect flawlessly to her Windows 8.1. I’m thankful that PowerShell is out of the box in all versions of windows. I do not think I’d have been able to walk her through this over the phone with this few keystrokes without PowerShell.

To the evil con artists who extort money from poor little old disabled ladies who work two jobs: please stop.

Getting a Windows Password for EC2 Instance

… without pasting your private key to ec2.

EC2 should never see your private key… because.. security!

I launched a Windows Server 2012 R2 instance in EC2 recently and while the AWS console does let you retrieve an Administrator password, it requires you to paste your PRIVATE key to AWS console to do it. I couldn’t bring myself to do it, so I learned how to use boto to get the encrypted password data and openssl cmdline to decrypt it to get the password.

Its a 2 step process with maybe the zeroth step being writing a .boto file with your aws credentials if you have never used boto.

import boto
import base64
ec2 = boto.connect_ec2()
inst = ec2.get_all_instances()[0].instance
data = ec2.get_password_data(inst.id)
open(‘ec2-admin-password’,’w’,write(base64.decodestring(data))

I’m assuming its the only instance running. If you have lots of others, use a list comprehension with if clause to filter to one on the get_all_instances() call, or just skip that call and paste an id string you see in AWS console for inst.id in the get_password_data call.

openssl rsautil -in ec2-admin-password -inkey .ssh/id_rsa -decrypt

You’ll be prompted for your private key password (and you MUST have a password. ssh-agent is easy) and then the Administrator password will be output to stdout.

 

Converting your existing ssh rsa key for use with Windows Azure

Oh Microsoft, it seems like you make simple things complex.

I could not find anything on converting an existing ssh key for use with Azure. Once I figured out what was needed and the commands available to me, it was easy. It only took me hours of fiddling with ssh-keygen and openssl.

The magic was learning that openssh stores its id_rsa in a format which openssl can read. This means I can use openssl directly to convert this private key.

openssl req -x509 -new -days 365 -key id_rsa -out id_rsa.x509req.pem

Type in your password for your private key (if you are not using a password, you should be.) Then fill out the certificate request fields.

Now you can boot your azure vm using id_rsa.x509req.pem

azure vm create jrwtest b39f27a8b8c64d52b05eac6a62ebad85__Ubuntu-12_04_3-LTS-amd64-server-20130916.1-en-us-30GB jwren –location “East US” -e -t id_rsa.x509req.pem

Now you can secure shell to your azure vm.

ssh jrwtest.cloudapp.net

SWEET. 🙂  No generating new ssh keys for me.

Where Windows Is Going

I’ve been stewing for about a day.

I did not go to Build Conference.

Once I figured out that WinRT is for Metro style apps and ONLY Metro style apps, and I tried to make a call from a .NET 4.5 app into a very simple “GetUserInfo” WinRT API and it threw an Access Denied Exception, I was upset.

Then I realized something.

This is not just a new way to program on Windows.

It is also not THE new way to program on Windows.

Microsoft is segregating their application types on purpose. Metro style apps and WinRT is not about “the next windows”. What was shown with the hybrid classic desktop and the new Metro UI is NOT the future vision that MSFT has for Windows. It is a transition.

Microsoft is posing Metro style and ONLY metro style to be the next development platform of a version of Windows that will not have the classic desktop. Some future version of Windows that won’t have Win32 and won’t have .NET. It will be WinRT on top of a Windows kernel and THAT IS ALL.

This is why that line between WinRT and .NET/Win32 has to stay thick and hard. There will be no hybrid apps. That ruins the vision.

win8-platform-and-tools Imagine a thick wall between the light blue and green.

Microsoft knows that it has to participate in a segregated market. They won’t be selling $100 Windows Professional licenses to OEMs of $300 tablet devices. The $10 license of Windows Started Edition is more like it. (I’m guessing at OEM costs.)

The operating system has to run fast on low power hardware. Any applications which run on it have to run on all the better and faster hardware, right on up to $5000 laptops. The Metro style along side classic desktop fits this mold.

I’m a little bit sad that they wouldn’t just come right out and say this. Come right out and say: “Hey! Our phones are going to run Windows 8! There will be 7”, 8”, 9”, 10”, 11”, 12” tablets all running Windows! But its not like any Windows that you’ve ever known!”

samsung-galaxy-tab-10-1-side-2-small-2

Talk about shaking things up! What if that were the first 3 sentences of the Build keynote?

I’m less angry about not being able to call WinRT from my .NET apps. But I’m a .NET developer. I’m not a Windows developer. I’m not a Silverlight developer. I’m not a WinRT developer.

I think in what I’m most disappointed is all that awesome stuff that WinRT makes easy, and out in .NET land, talking to a webcam for photos and video is still painful. Transcoding video is still painful. (Did you see how easy it is to transcode with WinRT? That is SWEET!)

Build Windows Day 2 From Afar: WTF is WinRT

Watching the developer reaction to Metro style and WinRT has been both depressing and comical. I suppose its like watching anyone else learn something from nothing. We can get it very wrong at first. It is part of our learning process.

I know I’ve not figured what the existence of WinRT means for .NET or what I can and cannot do between WinRT and.NET4.5. I’m also not sure what the difference is between Metro style and WinRT. It sure seems like there are some cool non-UI APIs in WinRT that I might want to use from .NET. I sure hope that I can.

At first glance it feels like Metro style apps aren’t .NET. At least not really. It feels like Metro style apps run in a different CLR. They feel like Silverlight on the desktop since they have no direct access to file system and the types available for use are limited.

I’ve read that it is not a different CLR. I’ve read that it is .NET but that the verifier and other tools in the chain of building a Metro style app enforce the restrictions. I’ll have to wait and see how the pieces fit together.

Missing the APIs can be a challenge: http://winmd.tumblr.com/post/10211942442/missing-net-apis

Looks like I can do the above when I say use some WinRT from .NET4.5. Cool, because those file pickers sure are pretty. http://ermau.com/using-winrt-from-net/

Doug Seven has an excellent post detailing what is being released and how it fits: http://dougseven.com/2011/09/14/i-know-what-youre-thinking-and-youre-wrong/

Take a look at this slide from the keynote:

win8-platform-and-tools

I’d like to speculate about a couple things related to this picture.

  1. This is not in the scale of overall importance to all developers. It is in the scale of what is new.
  2. All of the things in blue are still there and still supported.

Consider an alternative pitch for Metro style apps. Metro style apps, like all apps, are all launched from the new “Start Screen”. The start screen replaces the start menu. Metro style apps keep the look and feel of the start screen. It is as if you are never leaving the start screen. Metro style apps are apps that you program into the start screen. Imagine being able to program apps into the start menu. It sounds crazy. Now that your start menu is full screen and interactive, those metro tiles (they have a different name) are programmable by you. I can think of another little square in windows that is programmable: Sidebar Widgets. When was the last time you wrote a sidebar widget? (Mike Ward, you are the only one I know.)

Considered from the point of view, very few of us Line of Business app developers will be writing Metro style apps. They are not meant to replace all desktop apps. You will not see Office apps like Word, Excel or Powerpoint built as Metro style apps. They will likely get some theming that is Metro influenced, but they will still run on the traditional Windows desktop and not in the Start Screen. That said, there might be augmentations in the Metro style apps. After all, Windows on a tablet is far more usable with Office. So I think you will see stripped down, touch optimized, Metro versions of Word, Excel and Powerpoint. The use case for these will be “when you aren’t at your desktop or laptop".

Believe it or not, there was actually announcements around Azure and ASP.NET yesterday. You’d never know it given all the focus on WinRT. I’m super excited about the new async support for controller actions in MVC4. I also think Azure’s replication story around tables and blobs is pretty sweet now.

So much more to come. Its an exciting time be a developer. Just try to remember that ships often look like they are sinking when you see them far off the horizon Smile

Thoughts after the Build Windows keynote: This changes nothing

Nothing has changed, and this is a good thing.

Here is what I took away from yesterdays keynote:

  • Everything I’m doing today with Windows desktop apps will work on Windows 8. No surprise there.
  • If I want to write these new WinRT apps I’ll have to leave Winforms or WPF behind and use what looks like some kind of desktop Silverlight UI control library which has been enhanced with some more controls. (The GridView was shown in the keynote.)
  • There is nothing else to say about the developer story. Everything else shown in the keynote was about consumer experience.

Watching my own twitter feed was rather comical. Everyone seemed to be hearing exactly what they wanted to hear. Sometimes it was the opposite of what I thought I just heard.

There are still lots of unanswered questions, but I’m sure that in the next few days these will all be answered via sessions and blog posts containing the content of the sessions. I’m surprised people aren’t more patient. I’m actually seeing a bit of FUD email and tweets asking questions that should be answered by the end of the week. Be patient.

XAML Comments in Attributes.

Sometimes I wish that XML supported comments in attributes instead of just <!—style.

Almost always this is a XAML file that I wish had this.

Today I realized just how silly I was being.

xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"  xmlns:d="http://schemas.microsoft.com/expression/blend/2008"  mc:Ignorable="d"

And now I can just d:Anything=”any comment”.

Sure, I can’t nest my quotes there, but this is good enough for a lot of things.

<Grid d:Purpose=”this is the grid that contains the other grid that contains the things”>…

WCF Async Without Changing The Contract

Someone asked a group of people recently about how to prevent overloading a WCF service that gets blocked. It sounded like the WCF service was getting called a lot and this was causing many threads to get created to service all of the requests, but nearly all of those threads were blocked handling some IO requests.

I vaguely recalled something about WCF async and I suggested this person look into that. I even looked up the AsyncPattern=true property and value for the OperationContract attribute, but the person didn’t want to break the contract. I was pretty sure that this change was only a server side change and that it wouldn’t break any contract, but I wasn’t 100% sure.

Today I confirmed that I was right. The generated WSDL does not change when you change your contract from something like this:

[ServiceContract]

public interface IOrderService

{

[OperationContract]

Order[] GetOrders(int numOrders);

}

To something like this:

[ServiceContract]

public interface IOrderService

{

[OperationContract(AsyncPattern=true)]

IAsyncResult BeginGetOrders(int numOrders, AsyncCallback callback, object state);

Order[] EndGetOrders(IAsyncResult result);

}

If you want to convert existing WCF services to server-side async style, you can do so without your clients ever knowing. (There may be a caveat when using a ChannelFactory, see the docs.)

The MSDN docs are pretty good. An overview here http://msdn.microsoft.com/en-us/library/ms730059.aspx some better details here http://msdn.microsoft.com/en-us/library/ms731177.aspx

Dan Rigsby had some blog posts from when these features were rolled out, but beware his examples, he keeps a sync version and an async version, which is not strictly required. http://www.danrigsby.com/blog/index.php/2008/03/26/async-operations-in-wcf-iasyncresult-model-server-side/

Finally, Wenlong Dong’s blog gives great reasons why you would want this and even goes as far as suggesting using the async version of the datareader for async database access. http://blogs.msdn.com/b/wenlong/archive/2009/02/09/scale-wcf-application-better-with-asynchronous-programming.aspx

50 Simple Steps To Debugging IE7 Javascript

I had the need to debug javascript in IE7. After the Spoon studio distribution didn’t work for me in 64bit Windows 7, I decided to try the VM approach. Here are 50 simple steps to debugging Javascript in IE7 in a Virtual PC Virtual Machine.

* Download Virtual PC without XP Mode.
* Download IE7 VHD.
* Create a new VPC pointed to the VHD.
* upgrade the vpc integration components.
* defer the reboot.
* Install web developer toolbar.
* install Visual Studio WEb Dev Express 2010 which requires…
* WebPI which requires…
* .NET 2.0
* which fails because of the pending integration components installation.
* reboot.
* watch the upgrade fail when it prompts you for a XP CD ROM.
* Be happy that now you have no intergration components…
* Your mouse it now captured in the VPC window…
* be in awe of how much slower IE7 browsing is without the integration components.
* ITs so slow its going to be unusable for actual work so try installing the integration components again.
* Watch the installer simply fail with no explaination.
* Try WebPI again, even though it will be slow.
* be amazed at how long it takes to ngen System.Design.
* reboot after .net2.0 install.
* reboot after microsoft installer installation.
* be in awe of how long it takes SQL Express 2008 to install.
* reboot after web developer express partly installs.
* be in awe of how long you still have to wait for WebDevExpress to install.
* now that it is all done, try once more for the integration tools.
* get prompted for the CD again for usbhub.sys.
* search your system for this file. c:\> dir /s usbhub.sys
* curse when it is missing.
* google it (you don’t bing it at this point because of MSFT anger).
* after much clicking find this awesome post http://superuser.com/questions/244659/where-can-i-find-windows-xp-sp3-as-a-zip-file.
* nearly get a virus trying to get usbd.sys from memers.driverguide.com.
* find usbd.sys at sysfiles-download.com.
* complete integration components installation.
* wonder what this RemoteApp redirect is… sounds like Unity Mode on a mac for XP in Win7.
* reboot (to complete integration components installation).
* start Visual Web Developer and be in awe of how slow that first time launch is in a VM.
* Create an empty ASP.net web app and click run.
* see the 404 in IE7 and be happy because your browser is now attached to the VWD debugger.
* browse your site with the JS that kills IE7.
* click debug when IE7 prompts you.
* go back to VWD and see the JS open with cursor on the line with the error and no error message and no exception or other information about what is wrong with the JS.
* find a corner.
* sit down.
* curl into fetal position.
* rock yourself gently.
* sing yourself a slow and calm song.
* remember that you go home at 5pm and don’t think about software again until 9am tomorrow.
* be glad you aren’t one of those "passionate" devs that never stops thinking about software.
* think of your children.
* ask a coworker who knows js better than you and let them point to where you don’t have valid js.

WlanChannelInfo aka Windows 7 Net Stumbler aka Wifi Channel Info

I finally got around to updating WlanChannelInfo. It started because I wanted to play with some .NET 4 beta features and I also struggled with getting a simple net stumbler running. I figured that Windows had to have something better to offer, and it turns out that in windows 7 the WLAN API was updated to expose everything that I cared about. I really only want to see what WIFI channel’s my neighbors are on so that I can move my WIFI AP to an unused channel.

http://wlanchannelinfo.codeplex.com/

I finally updated it to use a .NET release instead of a .NET 4 beta, but when I did, I decided that I didn’t need .NET 4. I just stuck to using 3.5 so that this app will run out of the box on Windows 7. No need to get .NET 4 to run this. I figure my parents might have windows 7 but probably won’t have .NET 4 installed just yet. Maybe someone else’s parents would have the same issue, and since the download is only 19KB… yes, 19KB… since the app is dead simple and does nothing but use existing WPF controls and p/invoke into the WLAN api (via the ManagedWifi.dll also on codeplex) its *TINY*.

Let me know if you find this useful.