Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

i need to move my aplication to start up folder

ishraqishraq Member Posts: 20
hi.. im tryn to move my app into the start up folder.. heres the code im tryn to use..

'Add your application to the windows startup folder
On Error GoTo error
FileCopy App.Path & "" & App.EXEName & ".EXE", Mid$(App.Path, 1, 3) & "WINDOWSSTART MENUPROGRAMSSTARTUP" & App.EXEName & ".EXE"
Exit Sub
error: MsgBox Err.Description, vbExclamation, "Error"
End Sub

what parts should i change? do i have to put the name of my file in this? if so where? wen i do this it sez file not found.. im a complete beginner so pls be very specific.. i want this code to run on form load.... also i would like to move the exe file like cutting n pasting..n not copyin it.... thanks..any help would be fully appreciated.. :)

Comments

  • BitByBit_ThorBitByBit_Thor Member Posts: 2,444
    My guess would be you ran this code from the IDE (debugger) rather than compiling it into an EXE and then opening that file.

    Best Regards,
    Richard

    The way I see it... Well, it's all pretty blurry
  • ishraqishraq Member Posts: 20
    : My guess would be you ran this code from the IDE (debugger) rather
    : than compiling it into an EXE and then opening that file.
    :
    : Best Regards,
    : Richard
    :
    : The way I see it... Well, it's all pretty blurry

    hi Richard... thank u so much for replyn.. :)

    i ran it after compiling...still doesnt work... n this code is for copyin, not moving.. i wud like my app to be fully moved to the start up...

    thanks again.... waiting for ur reply...
  • BitByBit_ThorBitByBit_Thor Member Posts: 2,444
    :
    : hi Richard... thank u so much for replyn.. :)
    :
    : i ran it after compiling...still doesnt work... n this code is for
    : copyin, not moving.. i wud like my app to be fully moved to the
    : start up...
    :
    : thanks again.... waiting for ur reply...
    :

    Hmm... well then I'm going to sift through it nit-bitting (I believe that is what you call it).

    [code]
    [color=Green]'Add application to the windows startup folder[/color]
    Dim sSrc As String
    Dim sDest As String

    On Error GoTo error

    [color=Green]'You can not count on App.Path not adding the slash itself.
    'Actually, if App.Path is "C:" (or the root dir of any station)
    ' then App.Path comes with a free .[/color]

    [color=Green]'Also, I would like to note that EXEName is the name given at compile
    'The user can change the EXE Name in Windows afterwards and then this
    ' code wouldn't work. I don't have a work around - there might be a way
    ' of using Windows API's. If you think it'll be a problem, I could look
    ' into it for you once[/color]
    sSrc = App.Path & IIf(Right$(App.Path, 1) = "", "", "") & _
    App.EXEName & ".EXE"
    [color=Green]'Ofcourse, this code only works under Windows 95 and 98
    'The workaround is using an API call...
    'Ofcourse this is kind of complicated[/color]
    sDest = Mid$(App.Path, 1, 3) & "WINDOWSSTART MENUPROGRAMSSTARTUP" & _
    App.EXEName & ".EXE"

    [color=Green]'Btw, I found the error. Syntax is FileCopy "Dest", "Source"
    ' if I remember correctly[/color]
    FileCopy sDest, sSrc
    Exit Sub

    error:
    MsgBox Err.Description, vbExclamation, "Error"
    [/code]

    Best Regards,
    Richard

    The way I see it... Well, it's all pretty blurry
  • ishraqishraq Member Posts: 20
    : :
    : : hi Richard... thank u so much for replyn.. :)
    : :
    : : i ran it after compiling...still doesnt work... n this code is for
    : : copyin, not moving.. i wud like my app to be fully moved to the
    : : start up...
    : :
    : : thanks again.... waiting for ur reply...
    : :
    :
    : Hmm... well then I'm going to sift through it nit-bitting (I believe
    : that is what you call it).
    :
    : [code]:
    : [color=Green]'Add application to the windows startup folder[/color]
    : Dim sSrc As String
    : Dim sDest As String
    :
    : On Error GoTo error
    :
    : [color=Green]'You can not count on App.Path not adding the slash itself.
    : 'Actually, if App.Path is "C:" (or the root dir of any station)
    : ' then App.Path comes with a free .[/color]
    :
    : [color=Green]'Also, I would like to note that EXEName is the name given at compile
    : 'The user can change the EXE Name in Windows afterwards and then this
    : ' code wouldn't work. I don't have a work around - there might be a way
    : ' of using Windows API's. If you think it'll be a problem, I could look
    : ' into it for you once[/color]
    : sSrc = App.Path & IIf(Right$(App.Path, 1) = "", "", "") & _
    : App.EXEName & ".EXE"
    : [color=Green]'Ofcourse, this code only works under Windows 95 and 98
    : 'The workaround is using an API call...
    : 'Ofcourse this is kind of complicated[/color]
    : sDest = Mid$(App.Path, 1, 3) & "WINDOWSSTART MENUPROGRAMSSTARTUP" & _
    : App.EXEName & ".EXE"
    :
    : [color=Green]'Btw, I found the error. Syntax is FileCopy "Dest", "Source"
    : ' if I remember correctly[/color]
    : FileCopy sDest, sSrc
    : Exit Sub
    :
    : error:
    : MsgBox Err.Description, vbExclamation, "Error"
    : [/code]:
    :
    : Best Regards,
    : Richard
    :
    : The way I see it... Well, it's all pretty blurry


    hi, thanx for the help.
    i am learning so much from u..
    i tried it n it sez path not found.. this must be because im using vista right?
    u said earlier that it only works for win 98/95.. is there a way to make it work on xp and vista?
    thank u..

  • BitByBit_ThorBitByBit_Thor Member Posts: 2,444
    : hi, thanx for the help.
    : i am learning so much from u..
    : i tried it n it sez path not found.. this must be because im using
    : vista right?
    : u said earlier that it only works for win 98/95.. is there a way to
    : make it work on xp and vista?
    : thank u..
    :

    Actually, it's hell programming it.
    You're using VB6 right? Perhaps you should consider getting Visual Basic 2005 Express Edition, which can be downloaded for free. Ofcourse, I tell you know it's NOT the same as VB6. The syntax is mostly the same, so that's not much getting used to. However, the functions are somewhat different.

    Best Regards,
    Richard

    The way I see it... Well, it's all pretty blurry
  • BitByBit_ThorBitByBit_Thor Member Posts: 2,444
    : hi, thanx for the help.
    : i am learning so much from u..
    : i tried it n it sez path not found.. this must be because im using
    : vista right?
    : u said earlier that it only works for win 98/95.. is there a way to
    : make it work on xp and vista?
    : thank u..

    Basically, the information in XP is stored in (assumes C: is Windows Installation drive):
    C:Documents And Settings[italic]UserName[/italic]Start MenuProgramsStartup

    For UserName you can pick either the current user, or All Users.

    But note that this is only for english users!
    For instance, on my computer, it's:
    C:Documenten en settingsAll UsersMenu StartProgramma'sOpstarten
    (yes I'm dutch :P)

    I've been looking around for solutions, but basically it's hell.

    I *think* the constant needs to have value 7 for Startup.

    Supported Operating Systems:
    Windows 95 with Internet Explorer 5.0, Windows 98 with Internet Explorer 5.0, Windows 98 Second Edition (SE), Windows NT 4.0 with Internet Explorer 5.0, Windows NT 4.0 with Service Pack 4 (SP4)

    [code]
    Private Declare Function SHGetFolderPath Lib "Shell32.dll" ( _
    ByVal hOwner As Long, ByVal nFolder As Integer, ByVal hToken As Long, _
    ByVal dwFlags As Long, ByVal szPath As String) As Long

    Private Const FolderID As Long = 7&

    Function GetFolderPath() As String
    Dim sFolder As String

    sFolder = Space$(255)
    SHGetFolderPath 0&, FolderID, 0&, 0&, sFolder

    GetFolderPath = Left$(sFolder, InStr(1, sFolder, vbNullChar) - 1)
    End Function
    [/code]

    Not that this code is completely untested and I have no idea if it'll work or crash or anything... But if it does, you know where to find me ;)

    Best Regards,
    Richard

    The way I see it... Well, it's all pretty blurry
  • ishraqishraq Member Posts: 20
    : : hi, thanx for the help.
    : : i am learning so much from u..
    : : i tried it n it sez path not found.. this must be because im using
    : : vista right?
    : : u said earlier that it only works for win 98/95.. is there a way to
    : : make it work on xp and vista?
    : : thank u..
    :
    : Basically, the information in XP is stored in (assumes C: is
    : Windows Installation drive):
    : C:Documents And Settings[italic]UserName[/italic]Start
    : MenuProgramsStartup
    :
    : For UserName you can pick either the current user, or All Users.
    :
    : But note that this is only for english users!
    : For instance, on my computer, it's:
    : C:Documenten en settingsAll UsersMenu StartProgramma'sOpstarten
    : (yes I'm dutch :P)
    :
    : I've been looking around for solutions, but basically it's hell.
    :
    : I *think* the constant needs to have value 7 for Startup.
    :
    : Supported Operating Systems:
    : Windows 95 with Internet Explorer 5.0, Windows 98 with Internet
    : Explorer 5.0, Windows 98 Second Edition (SE), Windows NT 4.0 with
    : Internet Explorer 5.0, Windows NT 4.0 with Service Pack 4 (SP4)
    :
    : [code]:
    : Private Declare Function SHGetFolderPath Lib "Shell32.dll" ( _
    : ByVal hOwner As Long, ByVal nFolder As Integer, ByVal hToken As Long, _
    : ByVal dwFlags As Long, ByVal szPath As String) As Long
    :
    : Private Const FolderID As Long = 7&
    :
    : Function GetFolderPath() As String
    : Dim sFolder As String
    :
    : sFolder = Space$(255)
    : SHGetFolderPath 0&, FolderID, 0&, 0&, sFolder
    :
    : GetFolderPath = Left$(sFolder, InStr(1, sFolder, vbNullChar) - 1)
    : End Function
    : [/code]:
    :
    : Not that this code is completely untested and I have no idea if
    : it'll work or crash or anything... But if it does, you know where to
    : find me ;)
    :
    : Best Regards,
    : Richard
    :
    : The way I see it... Well, it's all pretty blurry


    hi, thanx for helping out!
    sorry for being so ignorant..but when i luk at this code its like my brain freezes..hehe...
    cud u pls get me a working copy if its not 2 much work? i mean with the registry clearer code?...thanx in advance..
    n yess i wud very much like to be a pro programmer like u 1 day, so im using learning vb6 now...but will move to .NET when i get better in this...
    btw im from Maldives... a small tourist destination in the Indian ocean..
    so nice to meet u..
    thanx so much for ur asistance!
    tc...best of wishes...

Sign In or Register to comment.