Windows启动时启动应用程序 [英] Making app startup when Windows starts

查看:120
本文介绍了Windows启动时启动应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我一直在与注册表打交道,以尝试在Windows运行时启动我的倒计时应用程序.它可以正常启动,但是运行时,Windows会在c:\ windows \ system32中查找带有时钟信息的文本文件,然后由于找不到该文件而崩溃.从目录运行应用程序虽然可以正常工作.本来我以为是因为我没有用引号设置注册表值.这是我设置值的方式:

Hi,

I''ve been playing around with the registry trying to get my countdown app to start when Windows does. It starts fine but when it runs, Windows looks for the text file with the clock info in c:\windows\system32 and then crashes as it can''t find it. Running the app from its directory works fine though. Originally I thought it was because I was not setting the registry value with quotes. Here''s how I''m setting the value:

Dim KeyName As String = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run"
                   Dim valueName As String = "Date Countdown"
                   Dim value As Object = Chr(34) & Environment.CurrentDirectory & "\Date Countdown.exe" & Chr(34)

                   Registry.SetValue(KeyName, valueName, value)

推荐答案

好,所以首先我认为这可能是权限问题.
带有时钟信息的文本文件是您自己创建的文件吗?如果是这样,请勿将其存储在C:\ Windows \ System32中,而是将其存储在用户应用程序数据目录中.可以使用以下命令找到该目录的路径:

Ok so first I think its probably a permissions problem.
Is the text file with the clock info a file you create your self? If so do not store it in C:\Windows\System32 instead store it in your users application data directory. The path to that directory can be found using the following:

'for current user
Dim path As String = 
    Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)
'or for all users
Dim path As String = 
    Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData)



这样,您可以确定不会出现权限问题.

我也会更改此代码



That way you can be sure there will be no permission problems.

Also I would change this code

Dim value As Object = Chr(34) & Environment.CurrentDirectory &"\DateCountdown.exe" & Chr(34)



对此



to this

Dim value As String = Application.ExecutablePath


只是为了使其更干净.


Just to make it cleaner.


认真吗?

为什么不使用启动文件夹?
只需将指针指向该应用程序,然后,一旦Windows启动,它将自动调用.

这是最简单的事情.

开始
所有程序
启动
打开


然后将应用程序拖到它.


等等,它将自动启动.
Seriously?

Why not use the Startup Folder?
Just put the pointer to the app there, then, once windows starts, it will call automatically.

It is the simplest thing to do.

Start
All Programs
Startup
Open


Then drag the app to it.


Et voila, it will start automatically.


这篇关于Windows启动时启动应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆