Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

autostarting application in specific directory

Status
Not open for further replies.

dima2

Programmer
Jan 20, 2002
85
0
0
LB
Hi,
I'm developping an application and I'm trying to make it run
automatically when windows starts.
I added a value in the registry
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run
where I specified the whole path of the executable
c:\Program Files\MyApp\MyExe.exe

It worked fine, the application started when windows started, now my
problem is
that it didin't start in it's directory
it started in c:
however I need it to start in c:\Program Files\MyApp (i want this to
be my working directory)

Is there a way to force it to start in a specific directory??
(you know, just like in a shorcut properties where u get to secify the
"target" and the "start in")

how can I do that??
 
At the start of your code. i.e. In the Form_Load or in the Sub Main() Put in these first Lines of Code.
[tt]
ChDrive "C:"
ChDir "c:\Program Files\MyApp\"
[/tt] Craig, mailto:sander@cogeco.ca

"Procrastination is the art of keeping up with yesterday."

I hope my post was helpful!!!
 
You could also make a shortcut to the program in Program Files --> Startup (I think it is called like this, in Dutch it is Programma's --> Opstarten). Shortcuts placed in there are executed at login time. In the shortcut you can set the current directory.

Marcel
 
I think he wants to hide the program opening, so that it is not removed easily. I had to do this for a program that was an in-out board at a company i used to work for.

The program would show at the front desk if the PC was on, and if it was locked or the screen saver was running. This way the front desk could see if the person was at their desk.

Some people didn't like the front desk knowing this so they removed the program from thier start menu. I had to hide it and have it run in the back-ground. Craig, mailto:sander@cogeco.ca

"Procrastination is the art of keeping up with yesterday."

I hope my post was helpful!!!
 
how can I add a shortcut programatically??
I could add the shortcut upon installation but
at some point in my program I might need to disable the autostarting, how could that be possible?
 
You would have to find the users start folder. There may be an API, to do this. Once you know what their start-up folder is you jsut copy a shortcut or the EXE to that folder. Craig, mailto:sander@cogeco.ca

"Procrastination is the art of keeping up with yesterday."

I hope my post was helpful!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top