计算机启动时执行程序 [英] Executing a program when the computer starts up

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

问题描述

大家好,
我正在使用Windows7.我有一个cpp程序,该程序从蓝牙设备读取信息并将其写入txt文件.我工作正常.
我希望它在Windows启动时自动开始执行.为此,我用语句
创建了一个批处理文件.

Hi everybody,
I am using windows 7. I have a cpp program which reads information from a bluetooth device and writes it to a txt file. I works properly.
I want it to start execution automatically when the windows starts up. for this purpose i created a batch file with the statement

"start /min C:\Users\wecare\Desktop\help\comport\Debug\comport.exe" 



并将其放在Windows的启动"目录中.好吧,它从Windows开始执行.但是问题是,当计算机启动时它自动开始执行时,它不会打开相关的txt文件并写入其中!但是,只要我正常执行它(在Visual Studio上),它就可以编写.
有什么主意吗?
谢谢...



and put it to Startup directory of the windows. Well,it starts execution with the windows. But the problem is that,when it starts execution automatically when the computer starts up, it does not open the relevant txt file and writes in it! However, it can write when i just execute it normally (on visual studio).
Is there any idea?
Thank you...

推荐答案

可能是由于权限-当应用启动时,没有用户登录,并且该应用没有访问权限文件.当您手动运行它时,它会从您的用户ID中获得它的权限,并且可以正常使用.

尝试更改文件(及其所在的文件夹)权限,以便任何人都可以读取和写入它.
或以特定用户身份运行该应用-谷歌可能可以为您提供帮助:
Probably, it is due to permissions - when the app starts there is no user logged in, and the app does not have permission to access the file. When you run it manually, it gets it''s permissions from your user ID and can work with it fine.

Try changing the file (and the folder it is in) permissions so that anyone can read and write it.
Or run the app as a specific user - google can probably help there: http://www.google.co.uk/search?sourceid=chrome&ie=UTF-8&q=execute+app+as+user[^] (I''ve never tried to do it, so I can''t be sure how)


如果您在源代码中使用相对路径,则可能需要将chdir设置为正确的位置目录.
If you use relative path in your source code,you may need to chdir to the correct directory before starting the program.


可能是您的程序开始工作时还没有准备好蓝牙.

如何编写有关打开蓝牙设备的操作的日志文件,看看它是否可以打开蓝牙(如果可以找到该设备,则更准确)

另一件事,在测试以及从启动时启动时,您还应该检查以哪种模式运行应用程序.导致应用程序模式(管理性和非管理性(诸如此类))也做很多事情.
may be your blue tooth is not ready yet when your program start working.

How about writing a log file on the action of opening bluetooth device and see if it can open the bluetooth(more accurately if it can find the device at all)

Another thing, you also should check in what mode you run your application when you test and when it start from startup. cause Application mode(Administrative and non administrative(something like that)) do a lots of deal too.


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

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