dcsimg


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: Spawning Processes as a different User

  1. #1
    Join Date
    May 2008
    Posts
    3

    Spawning Processes as a different User

    I've been searching for an answer to my problems for about 2 weeks now, so I finally decided to break down and ask here.

    Basic info: Windows Server 2003, Visual Basic 6.0

    Here's the deal. I have an app. that spawns processes of itself using the Shell() function. It passes a parameter, and if it detects this parameter it FTP's somewhere and does it's thing.

    When the EXE is ran, it will load all the FTP sites, spawn the processes, and generally does everything it's supposed to do.

    However, when used in conjunction with SRVANY.EXE and ran as a service, it seems to hit a process cap of around 42 then causes a desktop heap error (read the logs to find this). It doesn't make any messages, it just stops spawning processes. I imagine this is because it's being ran under SYSTEM instead of a User and that all the process it's spawning are being given the same rights.

    Is there any way for me to Shell this as a User instead of as SYSTEM while still loading it via a service? Or any other suggestions on what to do instead? I'd heard the idea of threads, but my experience with threads isn't exactly a good one.

    Thanks for any ideas or help with this.

  2. #2
    Join Date
    Aug 2004
    Location
    Orange, California
    Posts
    1,263
    You might try looking into the CreateProcessWithLogonW API

  3. #3
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,663
    Quote Originally Posted by stah
    I'd heard the idea of threads, but my experience with threads isn't exactly a good one.
    Multithreading is not an option you have with VB6. You would need to migrate to VB.NET for that.

    I'm unclear with respect to exactly what this app does, or is supposed to do. You gave a general description...perhaps something a bit more detailed and specific could "spawn" some other ideas.

  4. #4
    Join Date
    May 2008
    Posts
    3
    Hehe, clever choice of words.

    I assume all it does is FTP to several places and grab some reports. I was just kind of handed it, told the problem, and told to fix it.

    Maybe if I retry to explain what it's doing.

    Basically the app. runs in two modes. One mode is the main mode. This is achieved by starting the app. as any other app. All this one does is load in any file settings, then starts spawning processes of itself in the second mode.

    The second mode is the the work-horse (for lack of a better term). This is achieved by passing a parameter to the app. when loading it. This opens up the FTP, does it's work, then closes the FTP.

    Like I said, everything works fine when a user runs the app. but when it's launched as a service it will quit spawning processes after it reaches 42.

    I'm going to look into the CreateProcessAsUser thing linked earlier, but any other ideas will def. be heard out and appreciated. I was talking to someone else who told me to just kick off the processes in batches of 30 or so, wait for them to end, then do 30 more.

    So I'm willing to hear out non-conventional answers such as this as well. I'd just like to keep it as close to the original as possible, ya know.

    EDIT
    Found this in several places.
    Windows XP SP2 and Windows Server 2003: You cannot call CreateProcessWithLogonW from a process that is running under the LocalSystem account, because the function uses the logon SID in the caller token, and the token for the LocalSystem account does not contain this SID. As an alternative, use the CreateProcessAsUser and LogonUser functions
    Last edited by stah; 10-14-2008 at 10:30 AM.

  5. #5
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,663

Similar Threads

  1. Senior User Experience Researcher San Jose
    By Branta in forum Careers
    Replies: 0
    Last Post: 02-13-2006, 08:45 PM
  2. Script for scrolling
    By Mark in forum Web
    Replies: 3
    Last Post: 08-30-2001, 11:45 AM
  3. Replies: 0
    Last Post: 01-29-2001, 12:21 PM
  4. Replies: 2
    Last Post: 12-01-2000, 12:19 PM
  5. Replies: 0
    Last Post: 05-15-2000, 11:22 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center