日期:2014-05-19  浏览次数:20936 次

在vs.2005中打包时怎样写注册表,让程序下次开机时自动运行,还有安装完成后自动启动?--------很急--在线等..............
如题,

------解决方案--------------------
我也学习学习!!
------解决方案--------------------
开机自动运行的话,可以在HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run下面建一个string型value,值为你的可执行文件的路径

至于“安装完成后自动启动”,我还真不知道这还能通过修改注册表来完成……
你就让你的安装程序自己来启动不就成了么?
------解决方案--------------------
程序开机自动运行

string StartupPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Startup);
System.IO.File.Copy( "应用程序路径(包括程序名) ", StartupPath + "执行程序文件名称 ", true);

//获得文件的当前路径
string dir = Directory.GetCurrentDirectory();
//获取可执行文件的全部路径
string exeDir = dir + "WindowsApplication1.exe ";

//获取Run键
RegistryKey key1=Registry.LocalMachine;
RegistryKey key2=key1.CreateSubKey( "SOFTWARE ");
RegistryKey key3=key2.CreateSubKey( "Microsoft ");
RegistryKey key4=key3.CreateSubKey( "Windows ");
RegistryKey key5=key4.CreateSubKey( "CurrentVersion ");
RegistryKey key6=key5.CreateSubKey( "Run ");
//在Run键中写入一个新的键值
key6.SetValue( "myForm ",exeDir);
key6.Close();

//如果要取消的话就将key6.SetValue( "myForm ",exeDir);改成
//key6.SetValue( "myForm ",false);

------解决方案--------------------
开机自动运行的话,可以在HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run下面建一个string型value,值为你的可执行文件的路径
这个方便
------解决方案--------------------
顶一下。。
------解决方案--------------------
vainnetwork的对,也可以在runonce键值下,这样开机后只运行一次,以后开机就不运行了。
如果放在run下的话,你可以设置安装完成后删除键值。
------解决方案--------------------
帮顶~!
------解决方案--------------------
如果不涉及界面等.做个服务不就OK了??
没看明白,帮顶
------解决方案--------------------
安装完自动运行:
protected override void OnAfterInstall(System.Collections.IDictionary savedState)
{
base.OnAfterInstall(savedState);
path = this.Context.Parameters[ "targetdir "] + "你的程序.exe ";
System.Diagnostics.Process.Start(path);
}
写入注册表自启动:
private void WriteReg()
{
RegistryKey KeyCon = Registry.LocalMachine.OpenSubKey(
"Software\\Microsoft\\Windows\\CurrentVersion\\Run ",
true);
string MyKey = "你的程序 ";
if ((string)KeyCon.GetValue(MyKey, "no ") == "no ")//指定的键不存在
{
string Path = AppDomain.CurrentDomain.BaseDirectory + "你的程序.exe ";
KeyCon.SetValue(MyKey, Path); //设置注册表中的启动键
}
}
------解决方案--------------------
class WingRegeditWork : IWingRegeditWork
{