Click here to Skip to main content
15,881,852 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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" 


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...
Posted
Updated 26-Dec-11 22:49pm
v2

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)
 
Share this answer
 
If you use relative path in your source code,you may need to chdir to the correct directory before starting the program.
 
Share this answer
 
Comments
Mohibur Rashid 27-Dec-11 4:41am    
this is a good one
mstftrn 27-Dec-11 5:31am    
the txt file is in the same directory with the program, so i had just written
myfile.open ("oximetry.txt");
Did you mean that...
Lactoferrin 27-Dec-11 5:39am    
myfile.open ("oximetry.txt");tries to open currentdirectory\oximetry.txt
not dirofexefile\oximetry.txt
try cd C:\Users\wecare\Desktop\help\comport\Debug before start /min....
JackDingler 27-Dec-11 16:23pm    
Your permissions are restricted in the startup folder.

Try writing to a different folder.
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.
 
Share this answer
 
you bind your batch file with control panel schedule task program
 
Share this answer
 
Comments
mstftrn 27-Dec-11 5:28am    
I am sorry but i dont know how to do that...
Can you help please?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900