Start App with Windows 7 all profiles vs individual profile


I'm working on an app that will start with Windows 7 log on.  Each PC has about 30 users.  Because I'm lazy and I've had some permission problems with a different app writing to the registry for this I just set the installer to create a link in the all user startup folder.  I'd like to give individual users the option to not have it start up with their account only but leave everyone else's alone.  I use the following code to handle an entry in the users startup folder but then I get two entries in that users startup folder and the program starts up in a window instead of minimized to system tray like it should.  I've set the app to individual instance.  My suspicions are that I'll have to manage the start up link in individual profiles at time of installation (and somehow add it to users as they are added to that PC).  Is there an easy (lazy) way to manage this idea?  I don't necessarily need to allow users the ability to not have it startup, was just an optional feature.

 Private Sub chkStartWithWindows_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles chkStartWithWindows.CheckedChanged
        If Not FormLoaded Then Exit Sub
        My.Settings.StartWithWindows = Me.chkStartWithWindows.CheckState

            If Me.chkStartWithWindows.Checked Then
                 AddShortcut(Nothing, Nothing)
            End If
        Catch ex As Exception
            LogIt("ERROR putting startup startup path into startup folder." & ex.ToString)
        End Try
    End Sub

 Private Sub AddShortcut(sender As System.Object, e As System.EventArgs)
        Dim wshShell As New WshShellClass()
        Dim shortcut As IWshRuntimeLibrary.IWshShortcut
        Dim startUpFolderPath As String = Environment.GetFolderPath(Environment.SpecialFolder.Startup)

        ' Create the shortcut
             'Try to remove existing if its there

            shortcut = DirectCast(wshShell.CreateShortcut((startUpFolderPath & Convert.ToString("\")) + Application.ProductName + ".lnk"), IWshRuntimeLibrary.IWshShortcut)

            shortcut.TargetPath = Application.ExecutablePath
            shortcut.WorkingDirectory = Application.StartupPath
            shortcut.Description = "Launch MyAppat startup"
            shortcut.IconLocation = Application.StartupPath + "\MyApp.ico"
        Catch ex As Exception
            LogIt("Error creating a startup folder entry.   " & ex.ToString)
        End Try
    End Sub

    Public Sub DeleteStartupFolderShortcuts(targetExeName As String)
        Dim startUpFolderPath As String = Environment.GetFolderPath(Environment.SpecialFolder.Startup)
        Dim di As New DirectoryInfo(startUpFolderPath)
        Dim files As FileInfo() = di.GetFiles("*.lnk")      
        For Each fi As FileInfo In files
            Dim shortcutTargetFile As String = GetShortcutTargetFile(fi.FullName)

            If shortcutTargetFile.EndsWith(targetExeName, StringComparison.InvariantCultureIgnoreCase) Then
            End If
    End Sub
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Why create links during install when you could include the option to start on logon as part of the programs settings.
You can have set by default, the user will have to start it once. .....

In your approach, once the app is installed, any user login will trigger the start if the app.
zipnoticAuthor Commented:
Funny story.  That was my initial approach but I found the users were too afraid/ could t find/ didn't bother to run it ONCE.  Since they need it running they complained "something was wrong".

Perhaps iterating through the user folders found during install and placing there?
Instead of auto starting it for every logon, do you create a shortcut link on the desktop, start page?
That might be a better approach I.e they do not have to search for the application in the start, programs menu.
CompTIA Network+

Prepare for the CompTIA Network+ exam by learning how to troubleshoot, configure, and manage both wired and wireless networks.

zipnoticAuthor Commented:
I created a start up entry that shows up in everyone's folder.  Removing it from one profile removes it from all.  My code places an entry in that users folder which looks to be the same place but is actually a different roaming /user folder
I do not understand your last post.
During the install you can not account for all possible variations.
During the install, instead of linking into the all users profile consider adding it to the default user, but the issue will remain with existing user profiles, the default user will only impact new users.
zipnoticAuthor Commented:
The installer currently creates an entry in the startup folder for all users.  It works out OK but the app is thenrunning for everyone regardless if they need it or not. It should be possible to iterate through every profile and put a link in each users startup?  Can I run that code as part of the installer?  Will I have permission problems?  

Maybe its better just to leave it since 97% of the time users will want the program and if they don't need it then it won't bother anyone.  It just takes info from one program and transforms it for another.
You could iterate through every local profile, the issue deals with roaming.

Another option is to place a link to a script that on first login prompts for whether they need this apprunning, if yes, an entry the script checks for is added to the user as well as a login in the user's startup/login for the application to start minimized.

This way each user will be prompted once and will act accordingly there after.

Placing the shortcut on the desktop with default to run at startup registered on first run will be better in IMHO.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
zipnoticAuthor Commented:
Thanks much for thoughts.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.