Opening shorucut with VB application

hello there, I'm having a strange problem here...
i want to open up my "Mouse Properties" when my application starts...

i dont know if i can make it open it from the control panel directly but else, i have tried to create a shortcut to do open it from that.

now the problem is that the application seems not to be able to initiate any shortcuts, only other files or smt... at least it can find the other files with the:

If My.Computer.FileSystem.FileExists("c://Documents and Settings/Home/Desktop/Unused Desktop Shortcuts/New Textfile.txt") Then
MsgBox("File found.")
Else
MsgBox("File not found.")
End If

that works n it says that it finds the file n stuff... but it just cant find any of the shortcuts i have in that same folder... where i placed my mouse shortcut...
Also, im not sure how to actually execute this file, i tried with:

Dim openFileDialog1 As New OpenFileDialog()

openFileDialog1.FileName() = "c://Documents and Settings/Home/Desktop/Unused Desktop Shortcuts/Mouse"

openFileDialog1.OpenFile()

but no luck, not even when i try to open the found "New textfile.txt"

not really sure whats goin on here, its probably just me

any help is appreciated...
thanks


oh, n btw, i do have a last resort way of doin it... but that involves running a .bat file which executes 2 shortcuts w the program instead, lol... not v practical... but possible... n i can do that... well, did it already i just wanted a neater solution :)


Answer this question

Opening shorucut with VB application

  • Helenyeap

    well, that did really help.... but i had already tried w \ instead of / and it didnt work, i found smt in the help file n there it was / therefore i used / with which it also did find my textfile.txt
    it just couldnt find my shortcut...
    what i needed was for the program to start another program, from a shortcut to that program - Mouse Properties...
    since everytime i play that game, i need to take away acceleration, it just wont do it automatically.. and yes, that checkbox is enabled, and works for other games.. just not this 1...

    all i needed by the end of it was this line of code:

    Process.Start("c://Documents and Settings/Home/Desktop/Unused Desktop Shortcuts/Mouse")

    that opened the thing n then it worked

    so thanks anyway, it did help me :)

  • Heba El-Sherif

    Shortcut files have an extension of ".inf" if that helps you at all ;)

    I normally use batch files (.bat), but you should be able to open your text file...

    Give me a couple of tests, and I will see what I can find out ;)

    Oh, are you trying to load the text file into a TextBox or are you trying to load it externally (so it opens Notepad etc)

    edit: that and you have your backslashes the wrong way around! +_+ Try turning them around and use a single backslash after "C:"

    edit2: It may be more than what you are looking for ;)

    edit3: I used radio buttons to ask whether it should open in the textbox or using notepad. I didn't know how you want to load this text file. Please explain ;)

    Imports System

    Imports System.IO

    Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    Dim fr As StreamReader

    If File.Exists("C:\Documents and Settings\username\Desktop\text.txt") Then

    'Displays a message - File Found and then determine if the radiobutton is checked

    MsgBox("File Found!")

    'Determines if it is checked

    If rdb1.Checked = True Then

    'Launch the text file in notepad

    Process.Start("C:\\Documents and Settings\username\Desktop\text.txt")

    Else

    'Import the text file into "textbox1"

    fr = New StreamReader("C:\\Documents and Settings\username\Desktop\text.txt", True)

    TextBox1.Text = fr.ReadToEnd

    End If

    Else

    'Displays a message - File not Found

    MsgBox("File Not Found!")

    End If

    End Sub

    End Class


  • Opening shorucut with VB application