Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I need to make a program that acts as a shortcut.

 

I need to use ChDir() an Process.Start() functions. And it also has to have an icon.

 

I don't want any forms or any other extra stuff loaded in to slow my program down. How can I accomplish this the most minimalist way?

 

:cool: I'm using VB.NET 2003.

Posted

OK I'll try the Sub Main...

I started a new "Empty Project" and added a new module wich has the following code:

 

Module Module1
   Private Sub Main()
       ChDir("C:\")
       Process.Start("notepad.exe")
   End Sub
End Module

 

What else do I need for this, because it doesn't work?

 

PS: I really want to do this with VB. :-\

Posted (edited)

Batch programs are far more suited to this task. A good developer will use the best tools for the job, not just the ones he knows (or wants to know).

 

Why dont you just create a shortcut? Why exactly do you want to use VB for it?

Edited by Jay1b
Posted
Batch programs are far more suited to this task. A good developer will use the best tools for the job, not just the ones he knows (or wants to know).

 

Why dont you just create a shortcut? Why exactly do you want to use VB for it?

 

A simple windows shortcut doesn't change the directory (that's what I need the ChDir for). For example a program called DGIndex will create it's confuguration file to the directory where the shortcut is located instead of the program's folder. Besides I want to learn more about VB.

  • Administrators
Posted

If you bring up the properties for a shortcut there is an entry to change where it starts from (Start In).

If you wish to learn more about VB then this is possibly too simplistic an example (that is also fraught with problems outside of your control i.e. notepad.exe ignores the working directory for open / save dialogs), however a working sample looks like

 

Class SampleClass
   Public Shared Sub Main()
       Environment.CurrentDirectory = "c:\"
       Process.Start("notepad.exe")
   End Sub
End Class

just be aware that notepad will still default to the 'My Documents' folder...

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

  • Leaders
Posted
A simple windows shortcut doesn't change the directory (that's what I need the ChDir for)

 

Can't you specify working directory in a shortcut? Using an exe in place of a shortcut seems like overkill to me.

[sIGPIC]e[/sIGPIC]
Posted
Can't you specify working directory in a shortcut? Using an exe in place of a shortcut seems like overkill to me.

 

I tried to keep my question simple. There are also other advantages in using an exe. For example I can make my "shortcut" launch a certain operation in the destination program by simulating a keypress.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...