Windows SmartScreen prevented an unauthorized app from running - c#

I developed a c# software using windows 7. IDE is Visual studio 2010 professional, and the only dll it use is speech.dll. I generated an installer using the default way build menu->publish _software name_ -> Finish, when the setup wizard is on.
I provided the whole publish folder into 2 computers, windows 7 and windows 8. App installs fine in both machines but when it is about to run, windows 8 is saying Windows SmartScreen prevented an unauthorized app from running
Why is this happening? Please help!

Windows 8's SmartScreen is designed to "protect" consumers from malicious programs. In order to be trusted, you need to either buy a cert or sign up to distribute your application through the Windows Store (which costs less money).
It's a terrible move by Microsoft and will hurt devs like you, but there's currently no way around it. You will need to press "More information" when the SmartScreen alert comes up and then press the "Run" button to let your application run.

Related

getactiveObject command fails for windows 8 and windows 10

I have the following Powershell code below that i've compiled into an executable (.exe) file and have packaged it into SCCM to push against several 100 users. I have setup the SCCM package to run as "Install as user" and not as an Administrator. The package successfully captures the data for users with Windows 7, but any user that has Windows 8/10 installed fails to capture the data I need.
I did a try/catch statement and get this error - "
Exception calling "GetActiveObject" with "1" argument(s): "Operation
unavailable (Exception from HRESULT: 0x800401E3 (MK_E_UNAVAILABLE))"
I'm trying to understand why the same exact code works perfectly on Windows 7 machines, but does not work on Windows 8/10. Is there a fix? I would like to avoid using "New-Object -ComObject 'Outlook.Application'" because i don't want to create a new Outlook process in the background (fear of corrupting user's running Outlook session). I need to run the Powershell code to capture the active running Outlook process. Please help. Thank you
$mail = [Runtime.Interopservices.Marshal]::GetActiveObject('Outlook.Application')
$name = $mail.Application.DefaultProfileName
output of $name is stored locally to a log text file.
Make sure Outlook and your app are running in the same security context - either both apps are running with elevated privileges ("Run As Administrator") or neither app is running as an admin.
I was experiencing similar symptoms. I don't know if this is your exact problem, but maybe my solution will help someone else who stumbles across this issue.
The following MS KB article mentions that Office applications do not register themselves in the ROT until the application loses focus (which is apparently "behavior by design"). If the application is not registered in the ROT, GetActiveObject will return the error you indicated.
In my case, the script was working reliably on Windows 7, but it only sometimes worked on Windows 8. For some reason, perhaps related to the versions of Office installed, different versions of Internet Explorer (which I used to launch the Office apps) or maybe changes to Windows itself, I experienced different default window focusing behavior on Windows 8. As soon as I manually clicked on the Office app in my Windows 8 tests, the script started working.
To solve the problem, I just inserted a call to focus the Office application window before making the GetActiveObject call, which made the operation completely reliable on Windows 8.

Windows service fails to install through msi setup in few machines

I have developed an MSI setup with WiX, which includes a windows form application in c# .Net 2.0 framework and a windows service. When I run the setup, it gets installed successfully in all win 7, but fails in few win 7 and all win 8 machines by showing the privilege error ("Product: mysetup -- Error 1920. Service 'service displayname' (servicename) failed to start. Verify that you have sufficient privileges to start system services.") while trying to start the service at installation. Then I created an App.config file inside my windows service project and according to this link I wrote the following line which helped the setup get installed in all the win 7 machines till now, but no luck for any win 8 machine.
<runtime><generatePublisherEvidence enabled="false"/></runtime>
Regarding the service details, I have written the methods OnStart and OnStop inside my service. It actually starts the win form exe file at windows start-up. I have made the StartType property as Automatic at ServiceInstaller page and Account as LocalSystem at ServiceProcessInstaller page. I have also written the codes below inside WiX to install my service.
<ServiceInstall Id="ServiceInstaller" Type="ownProcess" Name="*******" DisplayName="******" Description="****** description" Start="auto" Account="LocalSystem" ErrorControl="ignore" Vital="yes" />
<ServiceControl Id="ServiceInstallerControl" Start="install" Stop="uninstall" Remove="uninstall" Name="******" Wait="yes" />
Presently, The setup and the windows service gets installed and runs fine in any win 7 machine, but fails in any win 8 and machine. Windows Event Viewer shows no detail but "msi setup fails".
Please note that, I have not added any ClickOnce or Publisher certificate yet for my application. I have planned to do it later, if that is not the reason for installation failure. How can I solve this or get the error details or debug this any way? Please help.
EDIT:
PhilDW's answer is very important to note. My win form application (.exe file) which my service tries to run, does not show up as a GUI but yes it actually interacts with the desktop and to achieve that I have followed and implemented this link. This is working fine on win xp and win 7 as of now and the service starts the win from app successfully whenever a user logs on. Not sure about win 8 or higher, hope this method does not get deprecated or blocked or barred by Microsoft Windows in higher versions for any security purpose (I mean, could this happen? what will be the solution then for interacting with desktop through LocalSystem windows service).
After Morten Frederiksen's answer I did the following. On one Win 8 (32bit) pc, I checked inside Windows->Microsoft.Net->Framework folder which contains 4.0 and 4.5 but no 2.0/3.0/3.5 exactly as told by Morten. Now, my win form app already contains the supportedRuntime entry in its App.config file as suggested by Morten, but no luck with the installation. So I added the same i.e.
<configuration>
<startup>
<supportedRuntime version="v2.0.50727"/>
</startup>
</configuration>
inside the App.config of my windows service (I think it's unnecessary) and ran the MSI after a rebuild, but the same thing happens, the installation rolls back displaying the same privilege error message. Then I tried to run my win form app manually. It shows the message "The app requires .Net framework 3.5. Would you like to download and install .Net framework 3.5 (2.0 and 3.0 included)". I clicked on "OK", it downloaded and installed the frameworks and ran the win form app .exe file successfully. Now that all frameworks are installed, I tried to reinstall my MSI and now it successfully gets installed and the service starts along with the app which actually does the desktop interaction now successfully.
So, Morten Frederiksen's answer helped me solve my case. It is clear now that in my case it is the absence of the required framework which caused the failure of the win form app which again caused the windows service to fail to start, which in turn caused the roll back of the MSI installation.
My guess is that you don't have .NET 2.0/3.0/3.5 installed on the Windows 8 PCs. By adding some configuration in your .config file you can enable .NET 2.0 applications on a system with only .NET 4.0/4.5 installed.
Here's how:
https://msdn.microsoft.com/en-us/library/jj152935%28v=vs.110%29.aspx
There are a few areas I'd look at, in no particular order. I'm assuming your forms app attempts to show UI, among some other assumptions.
You have wait=yes in the service startup. This causes Windows to wait until the service has started properly, the default wait time being 30 seconds. This means the service must get out of OnStart within 30 secs to show that it has in fact started ok. If there is a delay in there because of what's going on, you may find a timing issue could randomly cause it to finish within 30 seconds or not.
The second issue is probably more serious. I do not believe you can start a Winforms app from a service for the same reason that local system services can no longer interact with the desktop - it exposes a system account to the user's desktop for shatter attacks. This may be strictly enforced in Windows 8, so the Winform process dies and has a downstream effect on the service, depending how it's coded. This is relevant https://msdn.microsoft.com/en-us/library/windows/desktop/ms683502(v=vs.85).aspx
Finally, even if you could interact with the desktop there's a potential timing issue after reboots. If your service starts up and fires off the Winforms app, then this can happen before anyone has logged on, unless your code waits for a logon, because services run all the time when there is no interactive user, so your service is starting a Winforms app that tries to access a non-existent desktop. I don't know if you've handled this area or not.
I suggest you install your Winforms app and add a shortcut to the Start->Startup programs menu so that it starts when a user logs on. Then it can establish communication with the running service.

How to publish Windows Forms apps on the Internet for Windows 8?

I have uploaded my exe file to my server. But when user tries to download and run my app, he sees this message: "Windows SmartScreen prevented an unrecognized app from starting. Running this app might put your PC at risk." Of course he can click "More info" and choose "Run anyway". But how to avoid it? Do I need some special certificate? How can I get it?
What is the best way to publish Windows Forms apps on the Internet?
I tried ClickOnce, made setup file using InnoSetup. Nothing works, SmartScreen still shows up.
By the way, I'm Windows Phone developer, my apps have more than 3,000,000 downloads. Can use this fact somehow to become a trusted publisher?
Personally I would go for ClickOnce. And, yes, you need to sign your ClickOnce application with a certificate to be 'trusted' by Windows. You need a certificate with Authenticode to be precise.
See the related MSDN article on this. Make sure your certificate comes from a CA that is trusted without the need for additional certificates to be installed.

windows service written in c# .NET 4 vs2010 will not install on Server 2008 R2 Enterprise

I've written many versions of windows services and installed them on a 64-Bit system with 32 GB running Server 2008 R2 Enterprise.
I create the services using this recipe:
http://msdn.microsoft.com/en-us/zt39148a.aspx
"Walkthrough: Creating a Windows Service Application in the Component Designer"
I create the .msi and corresponding setup.exe on my Win 7 laptop (c#, vs2010 SP1, .NET 4).
NORMAL BEHAVIOUR
after testing a Windows service on my laptop, I copy the .msi and setup.exe to a folder on the win2008 R2 Enterprise server (using copy and paste via remote desktop); I use the server's Control Panel to uninstall, right click the .msi and choose Install, then walk through the Setup Wizard. No problem. Works most of the time.
ABNORMAL BEHAVIOUR
The install runs for perhaps 15 minutes or longer; it never finishes; eventually a dialog states
"(?) Installer is no longer responding."
with options to [Retry] or [Cancel].
At this point, the progress bar is a short as it could possibly be and at the far left, beneath the "P" of "Please wait...".
Clicking Retry does not help. It's been over 30 minutes and counting since I clicked Retry and the progress bar has not advanced even a pixel.
MORE INFORMATION
(a) the service installs without any problem on another server, a Win 2008 R2 web edition.
(b) as mentioned above, the Windows service both installs and works properly on my Win 7 development and testing environment.
HISTORY / SPECULATION
a couple of weeks ago, I was unable to install a service from the win 2008 R2 Enterprise server. I could not find it in Control Panel/Uninstall even though the .msi claimed it to be installed and the service also continued to appear in the services.msc console. Even disabling the service did not help. For that reason, I cloned the code, changed the service name slightly, and successfully installed that service which has been running for while without issues.
Today, a similar event happened, the only difference being that I can see that service in Control Panel Uninstall. Because it would not uninstall, I tried my same cloning trick but this time it failed.
Next step: using the above walkthrough, I created a do nothing Windows service and made it useful by importing my client classes into it from the original c# project file.
The re-built from the ground up Windows service works as designed on my laptop but refuses to install on the R2 Enterprise server.
Any ideas?
Please and thank you.
P.S.: i posted this at so because imho it's more likely something that a developer is likely to encounter prior to handing off her/his code to a sysadmin.
BTW, I could not find anything related at so; ditto via Google.
in this particular case, it is some very weird server rights condition
MORE INFORMATION
although my server account is not Administrator, I'm a member of both local and domain Administrators for this 2008 R2 box.
I had tried many ideas, including creating the example in the walkthrough and trying it. No luck.
The boxe's Administrator was able to install my service using installutil.exe so I tried installutil.exe but it would only work for me using the Administrator's credentials.
For that reason, I suspected it might be a rights issue, so I tried with my credentials installing the walkthrough example on the H:\ drive. Success. Next, I tried installing the troublesome Windows service on C: in a different location. Again, success.
What is strangest about this issue is that many times I had no problem then suddenly a problem arose to block my development efforts.
A sign that a Windows service will install is when a dialog asking permission to continue appears almost immediately after starting the install. Another clue that success is possible is being able to successfully uninstall any previous version via Control Panel.
I appreciate everyone's efforts to help me with this. Thank you.
I've had similar experiences with my own MSI's (not just for services), as well as third party MSI's on Win2k3 and Win2k8. I never (ever) got to the bottom of it without a 'fresh' re-install of the operating system.
Just like you, I too speculate that there's something lost in (a combination or all of) the internals of the OS (registry, file-system, system restore).
I know this is not what you want to hear but (if at all possible) a clean install of the OS might do the trick for you.

Embedding Mappoint 2010 Control in C# WinForm Creates Registry Error In Win7 (64-bit)

I have a WinForms application with an embedded MapPoint control that I've been maintaining for about 5 years now.
The application originally used MapPoint 2004, then 2006, and now we're upgrading to 2010.
Within my development environment (VS2008/.NET 2.0 for the project) the application runs fine.
Once I create an installer and install the app and try to run that, I start encountering problems. First the application prompts the UAC in Windows 2007 64 bit, though I don't have any code that modifies the filesystem or other protected systems.
If I choose "Yes" to allow the program to run, as soon as I try to create a new instance of a map to use within my map control
this._activeMap = this._mapCtrl.NewMap(MapPoint.GeoMapRegion.geoMapNorthAmerica);
I get a messagebox from MapPoint with the following error:
Your registry settings were not copied correctly. To correct these settings, run setup again for this application.
I'm aware of the KB article (http://support.microsoft.com/kb/314590) regarding this error in Streets & Tips, but MapPoint 2010 runs fine on its own, and as I said, the app runs fine from within VS or when run from a non-protected folder (e.g. if I do an x-copy of the files to my user's directory, it runs fine).
We received the same MapPoint error (along with others) on our install. We use NSIS for our install packages; once we ran it with elevated permissions the errors disappeared. I wish I could give you more details but I was not me who coded our installer. I was simply told how we got passed the MapPoint issue. I hope it at least points you in the right direction and helps you narrow your research.
Yes elevated install permissions are typically required anyway. My experience is more for MapPoint add-ins rather than apps that use the ActiveX control. There, I use the Visual Studio installed and Add-in Express, which has special settings for UAC handling. I don't think they have anything for using Office/MapPoint ActiveX controls, but it might be worth looking.

Categories