Results 1 to 5 of 5

Thread: can't run other Application in Windows Service

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2004
    Location
    Jakarta, Indonesia
    Posts
    818

    can't run other Application in Windows Service

    i created new windows service with timer inside it for scheduler purpose and it can run successfully but it can't run other application (ex: notepad) when the timer elapsed..

    i can see the process running in Task Manager but the notepad windows is not open

    i used this code in timer_elapsed event
    Code:
    AppLauncher oAppLauncher = new AppLauncher(@"C:\Windows\Regedit.exe");
                new Thread(new ThreadStart(oAppLauncher.StartProcess)).Start();
    where applauncher is a Class
    Code:
     class AppLauncher
        {
            string myAppPath = string.Empty;
    
            public AppLauncher(string _sPath)
            {
                myAppPath = _sPath;
            }
    
            public void StartProcess()
            {
                ProcessStartInfo oProcessStartInfo = new ProcessStartInfo(myAppPath);
                oProcessStartInfo.WindowStyle = ProcessWindowStyle.Maximized;
    
                Process oProcess = Process.Start(oProcessStartInfo);
            }
    
        }
    when i build windows App i can see Notepad open using the same code

    any insight?

    thanks

    1st NF - a table should not contain repeating groups.
    2nd NF - any fields that do not depend fully on the primary key should be moved to another table.
    3rd NF - there should be no dependency between non key fields in same table.
    - E. Petroutsos -


    eRiCk

    A collection of "Laku-abis" Ebook, Permanent Residence

    Access Reserved Words, a Classic Form Bug, Access Limitation, Know run Process and the Lock they hold in, Logging User Activity in MSSQL,
    Kill Database Processes

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: can't run other Application in Windows Service

    The Notepad window IS open, you just can't see it. Your service is not running under your user account, so it's not visible to your user. Just like Windows allows you to switch to a different user and run different apps under each one, so too a Windows service is generally run under a different user account and so any apps it runs will not be visible to your user.

    Windows services are not intended to interact with the user so they shouldn't do anything that requires user interaction. If you want to run an application at a specific time as a specific user then you should use the Windows task scheduler.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2004
    Location
    Jakarta, Indonesia
    Posts
    818

    Re: can't run other Application in Windows Service

    thx jmcilhinney

    i see, that's why..any way to force it?

    my intention using Windows Service is because User doens't need to add manually in Task Scheduler, especially if it's involved running 8-10 Application for period time..

    User only need to install the Service and make changes to XML since the Service will read the XML file for the Application need to be run

    hope it makes sense

    1st NF - a table should not contain repeating groups.
    2nd NF - any fields that do not depend fully on the primary key should be moved to another table.
    3rd NF - there should be no dependency between non key fields in same table.
    - E. Petroutsos -


    eRiCk

    A collection of "Laku-abis" Ebook, Permanent Residence

    Access Reserved Words, a Classic Form Bug, Access Limitation, Know run Process and the Lock they hold in, Logging User Activity in MSSQL,
    Kill Database Processes

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: can't run other Application in Windows Service

    You can specify the credentials for the account under which a Windows service runs.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2004
    Location
    Jakarta, Indonesia
    Posts
    818

    Re: can't run other Application in Windows Service

    can u show me the code?

    1st NF - a table should not contain repeating groups.
    2nd NF - any fields that do not depend fully on the primary key should be moved to another table.
    3rd NF - there should be no dependency between non key fields in same table.
    - E. Petroutsos -


    eRiCk

    A collection of "Laku-abis" Ebook, Permanent Residence

    Access Reserved Words, a Classic Form Bug, Access Limitation, Know run Process and the Lock they hold in, Logging User Activity in MSSQL,
    Kill Database Processes

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width