Nevron Gauge for SharePoint
Skip Navigation Links
C# Corner Home
Forum Home
Latest 50
Unanswered
Win Prizes
All Time Leaders
Jump to CategoryExpand Jump to Category
Login 
    Welcome Guest!
 Search Forum For :  
X
 Login
Please login to submit a new post, reply and edit exiting posts, see user profiles, and access more features. If you are not a registered member, Register here.
User Id / Email:
Password:  
Forgot Password | Forgot UserName
   Home » C# Language » App that starts when windows 7 starts
       
Author Reply
meb wed
posted 5 posts
since Feb 10, 2012 
from

App that starts when windows 7 starts

  Posted on: 10 Feb 2012       
I have a c# program that runs when windows os starts. The code does this by writing values to the registry. It is working fine on windows xp. But it is not working on windows 7 professional.
Sam Hobbs
posted  6490 posts
since  Sep 07, 2009 
from  Los Angeles, California, USA

 Re: App that starts when windows 7 starts
  Posted on: 10 Feb 2012        0  
Please tell us more. We do not have enough information to help you.
Thinking is a feeling; pleasant for some and unpleasant for others.
meb wed
posted  5 posts
since  Feb 10, 2012 
from 

 Re: App that starts when windows 7 starts
  Posted on: 10 Feb 2012        0  
Thanks for your reply. Here is the code that I am using...

When I start the program and click 'apply' to cause the program to start automatically with windows it gives an error which says "Requested registry access is not allowed" in win 7. But in win xp no problem at all. I am logged in to my system with an account which has administrator privilege.
 
private void SetStartup(string AppName, bool enable)
  {
  string runKey = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run";
 
  Microsoft.Win32.RegistryKey startupKey =  Microsoft.Win32.Registry.LocalMachine.OpenSubKey(runKey);
  if (enable)
   {
  if (startupKey.GetValue(AppName) == null)
  {
  startupKey.Close();
  startupKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(runKey, true);
  startupKey.SetValue(AppName, "\"" + Application.ExecutablePath.ToString() +"\"");
  startupKey.Close();
  }
  }
  else
  {
  startupKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(runKey, true);
  startupKey.DeleteValue(AppName, false);
  startupKey.Close();
  }
  }
 

 
  private void btnApply_Click(object sender, EventArgs e)
  {
  if (chkStartWithWindows.Checked)
  {
  SetStartup("winAuto", true);
  }
  else
  {
  SetStartup("winAuto", false);
  }
  }
Sam Hobbs
posted  6490 posts
since  Sep 07, 2009 
from  Los Angeles, California, USA

 Re: App that starts when windows 7 starts
  Posted on: 10 Feb 2012        0  
I don't know what to say. I hope another member can help you better.

Note that "Access Denied" is not always a security problem, so consider the possibility that there is some other problem. Have you tried updating the registry yourself directly, just to diagnose the problem? If you try that and there is a problem then that would probably be enough of a big clue that you can solve the problem.

I am not sure you are using try/catch; you might get better information about the problem if you do.

I had never heard of Eritrea.

Thinking is a feeling; pleasant for some and unpleasant for others.
meb wed
posted  5 posts
since  Feb 10, 2012 
from 

 Re: App that starts when windows 7 starts
  Posted on: 10 Feb 2012        0  
As you suggested I updated the registry directly, but no success yet...
Pravin Ghadge
posted  367 posts
since  Jun 23, 2010 
from 

 Re: App that starts when windows 7 starts
  Posted on: 10 Feb 2012        0  
Hi Meb,

For Windows 2007, make some setting:

1)Go to Control Panel
2)Then Action Center.
3)then click on change account setting.
4)there is seek bar which is at middle site. Switch that seek bar at bottom side
5)Click on Apply
6)Restart ur PC.

It may help u!
meb wed
posted  5 posts
since  Feb 10, 2012 
from 

 Re: App that starts when windows 7 starts
  Posted on: 13 Feb 2012        0  
Hello Pravin,

What you suggested might work.. but this is not the solution I am looking for. Suppose my app is installed on client computers. Do I have to give them this instruction along with my app. sounds crazy if I do that... and there is no such thing as windows 2007... it is windows 7.. any way thanks for your reply..
Sam Hobbs
posted  6490 posts
since  Sep 07, 2009 
from  Los Angeles, California, USA

 Re: App that starts when windows 7 starts
  Posted on: 13 Feb 2012        0  
What happened when you updated the registry directly? Were you able to do the update in the manner that you need the program to do it? Or did you get an error from doing it directly?

Did you put your relevant code in a try block with a corresponding catch block?
Thinking is a feeling; pleasant for some and unpleasant for others.
meb wed
posted  5 posts
since  Feb 10, 2012 
from 

 Re: App that starts when windows 7 starts
  Posted on: 13 Feb 2012        0  
I updated it in the manner that I needed the program to do it. And it wont start up with win 7. And I put it in try... catch block. It is generating the same error which says "Requested registry access is not allowed". I think it has to do with windows 7, the way it handles security. It is tighter than windows xp. I added an app.manifest file to enforce my app to run strictly under administrative privilege(Even though the user I am using to install my app is an administrator). Here is the app.manifest file.

<?xml version="1.0" encoding="utf-8"?>

<asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

  <assemblyIdentity version="1.0.0.0" name="MyApplication.app" />

  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">

    <security>

      <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">

        <requestedExecutionLevel level="requireAdministrator" uiAccess="false" />

      </requestedPrivileges>

    </security>

  </trustInfo>

</asmv1:assembly>

This successfully allowed me to write to the registry through my app. But again my app did not start when win 7 started... It really is confusing me..
Pravin Ghadge
posted  367 posts
since  Jun 23, 2010 
from 

 Re: App that starts when windows 7 starts
  Posted on: 13 Feb 2012        0  
meb

May be this is not a solution......
I know that we cannot tell our client to do this setting. But had u tried to do this setting.
Because Windows 7 have some restriction. this allows us to minimize that restriction.
       
6 Months Free & No Setup Fees ASP.NET Hosting!
Dynamic PDF
ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications. Visit DynamicPDF here
Introducing MaxV - one click. infinite control. Hyper-V Hosting from MaximumASP.
Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
Nevron Chart for .NET 2010.1 Now Available
The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
ASP.NET 4 Hosting
Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites - Click Here!
6 Months Free & No Setup Fees ASP.NET Hosting!
 Hosted by MaximumASP  |  Found a broken link?  |  Contact Us  |  Terms & conditions  |  Privacy Policy  |  Site Map  |  Advertise with us
Current Version: 5.2011.3.12
 © 1999 - 2012  Mindcracker LLC. All Rights Reserved