×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

autostarting application in specific directory

autostarting application in specific directory

autostarting application in specific directory

(OP)
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??

RE: autostarting application in specific directory

At the start of your code.  i.e. In the Form_Load or in the Sub Main()  Put in these first Lines of Code.

ChDrive "C:"
ChDir "c:\Program Files\MyApp\"

Craig, mailto:sander@cogeco.ca

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

I hope my post was helpful!!!

RE: autostarting application in specific directory

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

RE: autostarting application in specific directory

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!!!

RE: autostarting application in specific directory

(OP)
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?

RE: autostarting application in specific directory

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!!!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close