Sam Hobbs
posted
6490 posts
since
Sep 07, 2009
from
Los Angeles, California, USA
|
|
Re: App that starts when windows 7 starts
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|