CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 2004
    Posts
    132

    Startup shortcut with command parameters in Visual Studio?

    Hopefully someone can help me with Visual Studio. I am packaging a program and wish to have a shortcut installed on the users pc in the Startup folder, pointing to my application with a command parameter added. Any ideas how I would do this? Thanks in advance.

  2. #2
    Join Date
    Nov 2005
    Location
    Omaha, Nebraska, USA
    Posts
    696

    Re: Startup shortcut with command parameters in Visual Studio?

    You should be able to modify the package and deployment project provided with VB to create a custom Setup for your app.

    Here is a post that shows you how to modify the P&DW project to create a desktop icon for your program (not 100% sure if that works as intended). You should be able to change the project where it creates shortcuts in the Start Menu to also create a shortcut that passes command line parameters.

  3. #3
    Join Date
    Mar 2005
    Location
    Nottingham, UK
    Posts
    665

    Re: Startup shortcut with command parameters in Visual Studio?

    You can always use the API to add a new entry in the registry key - HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
    You just need to add a string which contains the path to your exe, and whatever command parameter(s) you want to pass.

    To retrieve the command parameters, interrogate the Command$ keyword in the form_load event.

    The only slight drawback to this is I am aware of at least one piece of anti-spyware software (Ad-Aware's Ad Watch) that can actively block changes to the startup section of the registry. Ad-Watch comes with Ad-Aware SE Pro (I'm not sure if you get it with the free version), and if you have it set to automatically block changes to the registry startup, no program can modify the keys or add new ones.
    (\/)
    (-.-)
    (')(')


    Bunny's quest for world domination continues.

  4. #4
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Startup shortcut with command parameters in Visual Studio?

    Another alternative would be to use Inno Script and Inno Setup, which can be downloaded from www.randem.com Inno Setup writes the script files that compile your app, and it's got a free trial version.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  5. #5
    Join Date
    Aug 2004
    Posts
    132

    Re: Startup shortcut with command parameters in Visual Studio?

    Thanks, I think I will add the entry in the registry. Looks like the simplest way.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured