Process.Start解决开机启动问题
2017-03-09 09:03
274 查看
问题
每天开机都会打开几个必要的程序,比如QQ、unity、浏览器这些,如果手动打开不仅没效率还影响心情,在开机启动里设置启动项是个不错的办法,但是过一段时间就会提示xxx.dll丢失,xxx.exe启动异常。。。
解决
利用UnityEngine.Application .OpenURL 或者System.Diagnostics.Process.Start来把这种风险降至最低。比如我平时要启动四个程序,现在只需要启动一个,大大降低了发生此错误的概率…
写完运行之后呢,打开是这个样子:
![](http://img.blog.csdn.net/20170309085941299?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvdTAxMzQ1MjQ0MA==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast)
addtask是添加一个任务,在下边框写入文件路径,
cleartask是清空所有的任务,
exit是退出程序,
每创建一个任务会生成对应的button,点击button会取消对应的任务
每天开机都会打开几个必要的程序,比如QQ、unity、浏览器这些,如果手动打开不仅没效率还影响心情,在开机启动里设置启动项是个不错的办法,但是过一段时间就会提示xxx.dll丢失,xxx.exe启动异常。。。
解决
利用UnityEngine.Application .OpenURL 或者System.Diagnostics.Process.Start来把这种风险降至最低。比如我平时要启动四个程序,现在只需要启动一个,大大降低了发生此错误的概率…
using UnityEngine; using UnityEngine.UI; using System.Collections; public class FontTest : MonoBehaviour { public Text text;//输入文本 public Text text2;//展示、提示文本 public Text text3;//提示文本 private GameObject button; private Transform canvas; int shiftY = 450; private IEnumerator Start() { button = Resources.Load("Button") as GameObject; canvas = GameObject.Find("Canvas").transform; index = PlayerPrefs.GetInt("Key"); if (index == 0) { PlayerPrefs.SetInt("Key", 0); text3.text = "没有可执行的任务"; } else { Debug.Log(index); text3.text = "本次执行的任务如下:\n"; text2.text = null; for (int i = 1; i < index + 1; i++) { yield return new WaitForSeconds(1); string filePath = PlayerPrefs.GetString(i.ToString()); System.Diagnostics.Process.Start(filePath); text2.text += PlayerPrefs.GetString(i.ToString()) + "\n"; GameObject clone = Instantiate(button); Button mb = clone.GetComponent<Button>(); mb.transform.SetParent(canvas); mb.gameObject.transform.position = new Vector3(990, shiftY, 0); shiftY -= 35; mb.GetComponentInChildren<Text>().text = filePath.Substring(filePath.LastIndexOf('/') + 1); string _key = i.ToString(); mb.onClick.AddListener(delegate { RemoveKey(_key, mb.gameObject); }); } } } public void RemoveKey(string key, GameObject game) { PlayerPrefs.DeleteKey(key); index--; PlayerPrefs.SetInt("Key", index); Debug.Log(game.name); text3.text = "已经移除------" + game.GetComponentInChildren<Text>().text; game.GetComponentInChildren<Button>().interactable = false; } private int index = 0; public void AddMisson() { int mIndex = PlayerPrefs.GetInt("Key"); mIndex++; string filePath = text.text.Replace("\\", "/"); PlayerPrefs.SetString(mIndex.ToString(), filePath); PlayerPrefs.SetInt("Key", mIndex); text3.text = "成功添加------" + filePath.Substring(filePath.LastIndexOf('/') + 1); GameObject clone = Instantiate(button); Button mb = clone.GetComponent<Button>(); mb.transform.SetParent(canvas); mb.gameObject.transform.position = new Vector3(990, shiftY, 0); shiftY -= 35; mb.GetComponentInChildren<Text>().text = filePath.Substring(filePath.LastIndexOf('/') + 1); string _key = PlayerPrefs.GetInt("Key").ToString(); Debug.Log(_key); mb.onClick.AddListener(delegate { RemoveKey(_key, mb.gameObject); }); } public void ClearList() { PlayerPrefs.DeleteAll(); text3.text = "已经清空完毕,请重新指定任务"; } public void ExitGame() { Application.Quit(); } }
写完运行之后呢,打开是这个样子:
addtask是添加一个任务,在下边框写入文件路径,
cleartask是清空所有的任务,
exit是退出程序,
每创建一个任务会生成对应的button,点击button会取消对应的任务
相关文章推荐
- 解决启动vsftp服务时遇到的问题 (Starting vsftpd startproc: exit status of parent of /usr/sbin/vsftpd)
- Win7如何提升为管理员权限,如何开机启动需要管理员权限的程序,解决win7开机不能自动运行的问题等
- c#Process.Start无法启动exe程序的问题
- 解决CentOS 与 Ubuntu 中 Android ADT Failed to start emulator无法启动AVD的问题
- 如何解决windows7开机后放大镜自动启动的问题
- 解决《新编全医药学大词典》开机启动及桌面快捷方式的问题
- 解决WINXP系统开机后弹出Generic host process for win32 services 遇到问题需要关闭!
- c#Process.Start无法启动exe程序的问题
- c#Process.Start无法启动exe程序的问题
- 安装Grid Control , OPMN Process Manager failed to start 问题解决
- 完美解决 开机无法启动 提示0xc000000e 问题
- 启动VMWare Server的GUEST OS时,开机速度过快无法按F2进入BIOS的问题和解决
- VMware虚拟机无法启动“Cannot find a valid peer process to connect to.”问题的解决
- 电脑开机不久就自动关机,并且要拔掉电源插头后再插回去才能再次启动的问题原因和解决方法
- 解决Strokeit在win8下的图标问题和开机启动问题
- Win7如何提升为管理员权限,如何开机启动需要管理员权限的程序,解决win7开机不能自动运行的问题等
- Oracle Start Up 2 Oracle 框架构件、启动、解决一个问题
- 解决ubuntu开机启动黑屏以及分辨率问题
- ibus开机自动启动问题---解决
- Oracle Start Up 2 Oracle 框架构件、启动、解决一个问题