1

I'm trying to understand how the trial licensing works for my Win32 app that I converted to a UWP app using the Desktop Bridge. The app was submitted to the Windows Store as a paid app ($1.99 per copy) with a 1 day trial.

So I downloaded it as a trial app onto my test Windows 10 machine and let it run for longer than 24 hrs w/o buying it.

After a day the app was still present on the computer (in the Start menu) but when I tried to run it again by clicking its Start menu icon, I was greeted by the following error:

A device attached to the system is not functioning.

enter image description here

So I'm curious if there's a way to present a more "user friendly" message for an expired trial app?

EDIT:: Found this page with this quote:

Trial license expires before the app is launched

If the trial expires before the user launches the app, your app won't launch. Instead, users see a dialog box that gives them the option to purchase your app from the Store.

but that's not what I'm seeing. I'm just getting that generic Windows launcher error that I showed above.

EDIT2:: Things have changed. According to Stefan Wick MSFT's post below this was a bug in OS that was addressed in the latest servicing update. So this ugly message is not shown anymore, although there can still be a bug when launching an expired app.

Here are the steps to reproduce:

1) Launch an expired UWP app. Now instead of the ugly Win32 launcher error (that I showed above) one would see this popup:

This app can't open

Your trial period for this app has expired. Visit the Windows Store to purchase the full app.

[Go to the Store] link
[Close] button

enter image description here Sorry, can't capture a better screenshot, because mine doesn't show anymore.

2) Click "Close" and the message will close and the app won't launch. Which is expected.

3) Click "Go to the Store" and the Store app will come up:

enter image description here

4) The "Launch" button in it works as expected, but ...

5) Click "Free trial" button (which should not even be there as the free trial for this app has expired long time ago. Mine was set to 30 days.) And the Store app will reload to this:

enter image description here

6) So now it shows "29 days remaining" which is totally bogus. I first installed this copy of the UWP app when I originally posted this question, which was way longer than 30 days, i.e. the trial period for this app.

7) But then if I click "Launch" it launches the expired app, which it shouldn't. Moreover, it also clears the expired app message that was originally shown in step (1) above. So now if I launch this app from the Start menu, it launches just fine.

I'm guessing it's still a bug, is it not?

Community
  • 1
  • 1
c00000fd
  • 20,994
  • 29
  • 177
  • 400
  • Hey c00000fd, this is a good question, I'm asking someone familiar with this area. – Franklin Chen - MSFT Oct 22 '16 at 08:02
  • @FranklinChen-MSFT: Thank you for responding to this. I can help you guys diagnose the issue. Please contact me via email in [my profile](http://stackoverflow.com/users/843732/c00000fd?tab=profile) for more details. – c00000fd Oct 22 '16 at 08:34
  • @c0000fd Have sent you an e-mail:) – Franklin Chen - MSFT Oct 24 '16 at 15:28
  • @FranklinChen-MSFT: Thanks. I replied with details. – c00000fd Oct 24 '16 at 18:20
  • I was bitten by this too. The store guys are aware of it and a fix is coming sooner or later. However I found a feasible way to track my own trial period and not rely on the store, buggy or not. The good thing with converted apps is that you have access to the real filesystem so you can leave tracks to tell the trial period. – nikos Nov 18 '16 at 18:44
  • @nikos: Thanks for confirming. The issue with keeping your own trial is that if the end-user waits for too long as then tries to run your app they will see this error that will totally confuse them. Unfortunately the only solution in this case is to uninstall and then re-install the app. I'm also glad to hear your optimism that the store guys would fix it soon. I'm not as hopeful though. There's another bug (among many) that reports license expiration date as `9999-12-31` that was there for a long time and still isn't fixed: http://stackoverflow.com/q/40201201/843732 – c00000fd Nov 18 '16 at 20:54
  • And also concerning your suggestion of keeping track of the time when the app was first installed -- that would work for as long as the UWP app is not uninstalled. A user can then re-install the app that will remove all of its previous data from the sandbox, thus the trial will start over. – c00000fd Nov 18 '16 at 20:57
  • what I'm doing is setting a trial in the store that NEVER expires, and I manage it from inside my program. If your program is a traditional desktop app, I am sure you already have code for that. As for cheeky users that will completely uninstall then reinstall, as I said you can drop marker files in the REAL filesystem and check them later. These won't go away after the app removal – nikos Nov 21 '16 at 13:30
  • @nikos: Really? I wasn't aware of it. I thought a Win32 app converted to UWP runs in a totally redirected sandbox so everything you "seem" to write to a real file system is redirected and then deleted when you uninstall the app. Can you give me a folder path that you write to that "survives" uninstallation? – c00000fd Nov 21 '16 at 20:25
  • think about it: if you had a desktop editor transformed to UWP, it wouldn't be much use if it only edited "phantom" files in a sandbox :) -- many folder locations are writeable, anything that a non-elevated program can reach. You could even create folders – nikos Nov 23 '16 at 06:50
  • ps. only appdata and system folders are "sandboxed", the rest are free to go https://msdn.microsoft.com/en-us/windows/uwp/porting/desktop-to-uwp-behind-the-scenes – nikos Nov 23 '16 at 06:57
  • @nikos: OK. I admit I didn't "bang" too hard on their redirection model to see how it works. So, again, what folder would "survive" reinstallation of a UWP app, can you give me an example? – c00000fd Nov 23 '16 at 19:17
  • just create a mystic named folder under %TEMP% and store your trial data there. Or if you are worried that the temp folder will be cleaned, create your folder under C:\. You can do whatever you like with folders, as long as you keep away from C:\windows, program files and such – nikos Nov 24 '16 at 07:15
  • @nikos: Oh. I see. That is interesting. So long as I don't write into user profile, system, ProgramFiles, or root drive the rest is available. That is an interesting approach. Thanks. – c00000fd Nov 24 '16 at 08:46
  • I have exactly the same issue right now. @FranklinChen-MSFT: Do you mind sharing your insight on how to fix this? – tseifried Jan 05 '17 at 12:48
  • @tseifried: This is a bug in Windows 10. And I don't think there's a fix yet. – c00000fd Jan 05 '17 at 21:22
  • @c00000fd: Yes, seems so. I have disabled the trial mode in the app for now. I also think that this could be related to the app not being visible in the app store yet. Could that be the case? – tseifried Jan 15 '17 at 07:50
  • @tseifried: It's hard to know. In my case I set this trial expiration to 30 days, so it's hard to test now. The only device that I can replicate this error on runs a previous version of the app, which is no longer in the store. But that doesn't prove your theory. What I think happens is that the app's executable file is digitally signed within the UWP package, and if that signature is broken a user will see that "device not functioning" error, which is just a dumb conversion of `ERROR_GEN_FAILURE` error code by the process loader in Windows. – c00000fd Jan 15 '17 at 08:51
  • To test my theory, open your UWP executable file in any hex editor and change a single byte in it. Then try to run it from the Start menu (as you would with your UWP app.) This will show the exact same error. So my conclusion is that there's a digital hash on the exe file + a timestamp, so if any are broken and don't match the signature, a user sees that `ERROR_GEN_FAILURE` error. The question is where is that signature? I looked all over the UWP package files and couldn't figure it out. It's all undocumented. – c00000fd Jan 15 '17 at 08:55
  • So if you get to it, one can use the timestamp on the file signature to calculate how many days are left in the trial license and warn the user with a more graceful message. – c00000fd Jan 15 '17 at 08:55

1 Answers1

1

This was due to a bug in the OS, which has been fixed by now.

Thanks, Stefan Wick - Windows Developer Platform

Stefan Wick MSFT
  • 13,600
  • 1
  • 32
  • 51
  • Thanks for acknowledging it, Stefan. By saying, "fixed" you mean "Creator's update", correct? Also what exactly happens instead? Can you elaborate? – c00000fd Apr 15 '17 at 20:35
  • 1
    We fixed it in a recent servicing update for the Anniversary Update (and it's also fixed in Creators Update of course). Instead of the ugly error box, we redirect the user to the respective product page in the Store. – Stefan Wick MSFT Apr 15 '17 at 20:40
  • Stefan, I was able to test it. So even though the original bug was fixed, there may still be an issue. Please see my edit2 above. [Use my email](http://stackoverflow.com/users/843732/c00000fd?tab=profile) if you need to contact me for details. – c00000fd Apr 15 '17 at 21:37
  • Following up offline on the new issue. May want to start a new question. I have sent you an email just now. – Stefan Wick MSFT Apr 15 '17 at 23:13
  • Good idea. I replied to your email. – c00000fd Apr 15 '17 at 23:33