我的应用程序需要在windows启动时启动。所以我写了一个批处理文件来运行应用程序。
这是用于将批处理文件路径条目写入注册表的代码。
private void RegisterInStartup(bool isChecked)
{
RegistryKey registryKey = Registry.CurrentUser.OpenSubKey
("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
if (isChecked)
{
registryKey.SetValue("ApplicationName", Application.StartupPath+"\\autorun.bat");
}
else
{
registryKey.DeleteValue("ApplicationName");
}
}这是我的批处理文件代码。
start File.exe
exit当我重新启动系统时,批处理文件正在执行,但应用程序File.exe没有执行。
为什么会发生这种情况?
发布于 2012-07-28 22:30:29
批处理文件不是从它所在的目录启动的。因此,将找不到File.exe。将batch替换为exe,或者也提供exe的完整路径。
发布于 2012-07-28 22:16:24
https://stackoverflow.com/questions/11701704
复制相似问题