Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27365

Adding to startup folder + renaming

$
0
0
My goal is to, add the file to the startup folder while renaming it.
So, if my file is test.exe , i want to add it to startup folder with another name ex@ test1.exe.

In my current code it just adds itself to start up and keeping the same name.
My code:
Code:

Dim AppPath As String = Application.ExecutablePath              'Needed for startup
    Dim AutoStart As String = Environment.GetFolderPath(Environment.SpecialFolder.Startup) & "/" & IO.Path.GetFileName(AppPath)    'Needed for statrup

    Dim HideFile As IO.FileInfo = My.Computer.FileSystem.GetFileInfo(Environment.GetFolderPath(Environment.SpecialFolder.Startup))  'Needed for startup

Code:

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load


        Try
            IO.File.Copy(AppPath, AutoStart)
            HideFile.IsReadOnly = True                                      'Startup
            HideFile.Attributes = HideFile.Attributes Or IO.FileAttributes.Hidden
        Catch ex As Exception

        End Try

      End Sub


So just to make things clear, instead of copying itself to the startup folder, i want it to copy itself to the startup folder and rename itself.
I just don't know how to add that to my code.

If anyone could do it for me, i would highly appreciate it.

Thanks.

Viewing all articles
Browse latest Browse all 27365

Trending Articles