Program is not starting at windows 7 startup - c#

I read some topics here, but I haven't found the solution of my problem.
I wrote application(C#, WPF, EF, sql server compact) that should start at windows startup. I tried to achieve that in two ways:
Add entry to windows register. Unfortunately that wasn't work on Windows 7. I found here that adding a shortcut to Startup folder can solve my problem...
I've added shortcut to my application in Startup folder. Unfortunately again it is not working...
My application is starting with admin permissions because is using external dll's sql server compact. Maybe this is reason? In addition my application is not signed and probably will not be. Also writing a wcf service could be bad idea in my application.
Do you have any suggestions, or solutions for that problem?

It's against windows guidelines ( and enforced by the operating system ) to put a program that requires UAC elevation in the startup process. It's a horrible user experience to be prompted for elevation every time they logon to a computer.
I would factor the wcf / sql into a service and keep the client side UI elevation free.
Reference: Error message when you start a Windows Vista-based computer: "Windows has blocked some startup programs"

The solution for that problem was to make user to install sql server compact on his own computer instead of embeding it in application folder and change permissions for application to asInvoker from admin.

Related

C# Blazor project running as Windows Service

I'm pretty new to this.
I have a c# blazor project which is using SQLite Database on .Net6.0
I'm trying to turn this into a windows service, so I can run it on a windows server (Win 10).
I followed steps here
but when I try running the service via "Windows Services" on my local computer, I get this error:
Windows could not start the service on Local Computer. Error 5:Access is denied.
and on the windows server it starts and immediately stops.
I checked Event Viewer and there wasn't any details about why that's it.
Do you if I need to do more stuff for it to run? specially DB wise?
I can't find good info on internet :(
I fixed it.
So, follow the link and it should work. I had some other problems with IP and Port.
and just that you don't need to change anything for your DB. You probably need to add an automatic DB migration which you can find it here.

Force c# windows service to always run as system and not allow stop/start by non-privileged users

I am new to building Windows Services, As a learning exercise I am following the template provided by Visual Studio in order to write a service which will block specific users from using the CD drive and logging attempts to a file. I haven't been able to find documentation that would allow me to 1) prevent non-elevated users from stopping or restarting the service and 2) force the service to run as NT Authority\SYSTEM and prevent the user from changng the 'run as' user. Any tips would be appreciated. I have searched the internet and stack overflowbut perhaps I just dont know enough about services or the relevant terminology to find what I need. Thanks in advance!
I rewrote my project to take advantage of PSService a PowerShell script by JFLarvoire (available on GitHub) which dynamically generates a customizable Windows Service executable. You can reconfigure PSService to specify what user the service should run as but by default it runs as the SYSTEM account which met my needs perfectly. Further research has also shown that unprivileged Windows users can start a system service but cannot stop them unless they have been granted permission to do so.

Trick windows into thinking it just rebooted

We have an application that needs get from an Administrator account to another limited account and the other way around. Currently we are setting the auto logon in the registry, then reboot the machine. This takes up to 3 reboots as the machines are EWF enabled. Our customer support just cannot sit around and wait for the remote machines to reboot while there's an angry customer on the phone.
We have a windows service and a ui running on the machines (written in C#). Most of them are windows 7, but some are windows xp and windows 8.
I was wondering if anybody here knows a way to maybe trick windows into thinking it was just rebooted and auto log into an account. Anybody know of anything? I do know there are tricky ways to log into an account automatically from the login screen, but as far as I understand that's going to require writing a module to replace GINA in windows XP, and in windows vista and up, since GINA was replaced with a "Content Provider", writing a Content Provider or something, both of which seem overkill, but a possible future solution. Any ideas?
NOTE: We are not switching between accounts so that the application can run a process under that account, we are switching between accounts so real people have either administrative access or limited access to the computer. Hope that makes it a little more clear
If you have an application that needs to run between other users and an administrator, you should be creating a launcher application. The launcher application should be using Process.Start() to start your application. You can supply ProcessStartInfo arguments to Process.Start() so that you can run the application using different credentials.
Here'some help. For Xp, there's a simple registry key that does it (search google for AutoLogon), for Win7, it's a bit more complex. See this topic:
http://answers.microsoft.com/en-us/windows/forum/windows_7-security/how-to-turn-on-automatic-logon-in-windows-7/99d4fe75-3f22-499b-85fc-c7a2c4f728af
I think we had something like this running somewhere, but it wasn't my task and the collegue is on vacation this week. Maybe the above link helps, i'll ask him otherwise.

CD Burning within an XBAP

I have an XBAP that needs to be able to burn cd's. When running from inside Visual Studio, everything works okay. However when running from a browser, the IMAPI dll reports that the environment is not supported as soon as it tries to access the drive.
I am assuming this is coming down to permissioning. I have a signed certificate which I have installed and the xbap is set to run as a full trust application (although I'm guessing that it can't be or I wouldn't be having this problem).
Currently this is all running on my local machine, however eventually I want this to be deployed to a web server (all users will already have the certificate installed on their clients).
Does anyone have any ideas as to what I've missed / done wrong?
Update:
I have tried creating a new, test certificate which I've installed in my certificate store and then signed the XBAP against it, but it makes no difference.
Really could do with some ideas if anyone has any?
Further Update:
I have created a console application which is able to burn cd's. Shelling out to this console application allows me to burn the cd from my xbap, but not from inside the xbap itself.
However, this is really not what I want. Ideally I want to have all this contained within the xbap. Failing that, is there a way to include the console application in the xbap's one click deployment?
Thanks
I believe this is not possible to do with XBAP. According to MS documentation on XBAPs,
Examples of permissions not available
in the Internet zone:
FileIOPermission - This permission controls the ability to read and write files on disk. Consequently, applications in the Internet zone cannot read files on the user's hard disk.
RegistryPermission - This permission controls the ability to read/write to the registry. Consequently, applications in the Internet zone cannot access or control state in the user's registry.
SecurityPermission.UnmanagedCode - This permission controls the ability to call native Win32 functions.
When you run your XBAP over the internet, you'll hit issue #3: trying to interop with unmanaged code.
I would recommend deploying your app as a stand-alone app with ClickOnce. That way, you can have full access to the system, but still get easy deployment and upgrades like you do with XBAP.
*edit*
One thing you could try -- and I can't guarantee it will work -- but you could have your users go into IE Internet Options, add your site to the trusted sites list. I'm betting then your CD burning code will work because it will be in the trusted zone, rather than the Internet Zone.
Try going to
HKLM\SOFTWARE\Microsoft.NETFramework\Windows Presentation Foundation\Hosting
in the registry
create a new DWORD named RunUnrestricted with value 1.

C# application is freezing on vista/7, not on xp/2003 server

I wrote a C# application that is running well on my xp development machine.
When my client is running it on different PC, it seems to freeze on both vista and 7 machines.
I would like to know if there is any issue on running dotnet applications on vista/7.
I compiled the application for both framework 2.0 and 3.5 but it didn't help.
The log file neither doesn't help.
Is there any way to know where is the application freezing (of course, the client doesn't have VS for attaching to the application) ?
Thank you in advance for any help.
Pierre.
Generally, .NET application should run the same on any Windows version with .NET framework installed. Most common problem that occur are related to the new User Account Control policy in Vista and 7, which prevents applications from accessing areas requiring elevated privileges (which would otherwise run fine under an Administrator account in XP).
For example, if your application is trying to write configuration settings to the Program Files folder (which is a really bad idea, btw), or is using some hardcoded disk or registry paths instead of environment variables provided in .NET classes, it may fail under Vista.
To quickly check if this is an UAC privilege problem, try to run the application as an administrator (have your client right click the .exe file and select Run as Administrator). If it works, then this suggests that you need to examine your code and update it to make sure you are only accessing allowed areas.
Check this link for more information: Making apps UAC aware.
As redsquare suggested, the best way to test your application in a variety of Windows systems is to run them in several virtual machines (MS Virtual PC or VMWare Player, both of them free for download).
You do not give much information in order for us to help a great deal.
I would start by trying to recreate the issue locally on a virtual machine (vista one available here) and then profiling the app with something like memprofiler.
Ask your client to capture a process dump using Windows Task Manager,
In Task Manager, find the process that hangs.
Right click and capture a memory dump.
Then you can do some analysis on the dump to see why it hangs.
If you are not familiar with dump analysis, find someone who can help or open a support case via http://support.microsoft.com
csharp applications are supposed to run on vista/win7. This is their home:)
Your problem is not the OS. its your application.
Most probably the application is looking for a file, a folder, something on the client side that is not there and its freezing. this is my experience.
Check for project independencies and make sure you have shipped to your clients everything your project needs.
and last, distribute to one client the debug version with debug messages enable and get the feedback from their system.

Categories

Resources