App that starts when windows 7 starts
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.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Pravin GhadgePosted Feb 13, 2012, 7:52 AM
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.
meb wedPosted Feb 13, 2012, 12:55 AM
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..Sam HobbsPosted Feb 13, 2012, 12:11 AM
Did you put your relevant code in a try block with a corresponding catch block?
meb wedPosted Feb 13, 2012, 12:00 AM
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..
Pravin GhadgePosted Feb 10, 2012, 8:25 AM
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 wedPosted Feb 10, 2012, 6:14 AM
Sam HobbsPosted Feb 10, 2012, 4:44 AM
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.
meb wedPosted Feb 10, 2012, 3:16 AM
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 HobbsPosted Feb 10, 2012, 2:56 AM