simple service

Posted on 2004-10-22
Last Modified: 2010-04-14

I have a batch file that I have to run ON the server, in order to compile some code, whenever I change the code.  In order to do this, I have to TS into my W2K server and run the batch file.  Is there any way I can just make my batch file a service or something that I can run remotely?  The batch file has to run from a certain directory on the server, and I don't want to share that directory, so I can't just run the batch from my work station.  It looks like this:

cd "F:\inetpub\wwwroot\services\aspnetstore\Components"
csc /t:library /out:../../../bin/Ccmtees.dll localFilesHere.ext

.. more commands here ...


Question by:trevorhartman
    LVL 95

    Expert Comment

    by:Lee W, MVP
    You could use the scheduled tasks control panel and schedule it to run periodically.  A service is typically something that runs all the time.  You want the code CONSTANTLY recompiled?  Doing so might lock the file your trying to program/edit.  I'd say go with the scheduled task.  Run it every 5 minutes if you want, but don't make the batch file a service per se or you may have MANY problems trying to use it.

    LVL 8

    Author Comment

    as you can probaly tell i don't really know what i'm talking about :)

    I only need to compile my code RIGHT after I edit it... So I don't want to make it a service.  I would like to make it into something that I could just run from the commmand line on my workstation.. is there some kind of net start syntax or something that could tell the server to run the batch?
    LVL 95

    Expert Comment

    by:Lee W, MVP
    If you really want to make it a service, look into srvany - an NT resource kit utility that I'm all but certain is available/included for Windows 2000.
    LVL 8

    Author Comment

    well I don't really want to make it into a service, if that's not the right way to go..  i mean, what do you recommend?  I'm telling you what I need - the ability to run something on the server by typing a command on my workstation..  Does that require making a service, or is there an easier way?
    LVL 95

    Expert Comment

    by:Lee W, MVP
    Ok, so you want to edit the program on your workstation, then have your workstation kick off the script on the server so that you don't have to terminal in, right?
    LVL 95

    Accepted Solution

    Try downloading the free PSTOOLS from  One of the tools included is "PSEXEC" - here's some info about it:

    PsExec v1.55 - Execute processes remotely
    Copyright (C) 2001-2004 Mark Russinovich
    Sysinternals -

    PsExec executes a program on a remote system, where remotely executed console
    applications execute interactively.

    Usage: psexec [\\computer[,computer2[,...] | @file][-u user [-p psswd]][-n s][-s|-e][-i][-c [-f|-v]][-w directory][-d][-<priority>][-a n,n,...] cmd [arguments]
         -a         Separate processors on which the application can run with
                    commas where 1 is the lowest numbered CPU. For example,
                    to run the application on CPU 2 and CPU 4, enter:
                    "-a 2,4"
         -c         Copy the specified program to the remote system for
                    execution. If you omit this option the application
                    must be in the system path on the remote system.
         -d         Don't wait for process to terminate (non-interactive).
         -e         Loads the specified account's profile.
         -f         Copy the specified program even if the file already
                    exists on the remote system.
         -i         Run the program so that it interacts with the desktop on the
                    remote system.
         -n         Specifies timeout in seconds connecting to remote computers.
         -p         Specifies optional password for user name. If you omit this
                    you will be prompted to enter a hidden password.
         -s         Run the remote process in the System account.
         -u         Specifies optional user name for login to remote
         -v         Copy the specified file only if it has a higher version number
                    or is newer on than the one on the remote system.
         -w         Set the working directory of the process (relative to
                    remote computer).
         -priority      Specifies -low, -belownormal, -abovenormal, -high or
                    -realtime to run the process at a different priority.
         computer   Direct PsExec to run the application on the remote
                    computer or computers specified. If you omit the computer
                    name PsExec runs the application on the local system,
                    and if you specify a wildcard (\\*), PsExec runs the
                    command on all computers in the current domain.
         @file      PsExec will execute the command on each of the computers listed
                    in the file.
         program    Name of application to execute.
         arguments  Arguments to pass (note that file paths must be
                    absolute paths on the target system).

    You can enclose applications that have spaces in their name with
    quotation marks e.g. psexec \\marklap "c:\long name app.exe".
    Input is only passed to the remote system when you press the enter
    key, and typing Ctrl-C terminates the remote process.

    If you omit a user name the process will run in the context of your
    account on the remote system, but will not have access to network
    resources (because it is impersonating). Specify a valid user name
    in the Domain\User syntax if the remote process requires access
    to network resources or to run in a different account. Note that
    the password is transmitted in clear text to the remote system.

    Error codes returned by PsExec are specific to the applications you
    execute, not PsExec.
    LVL 8

    Author Comment

    looks good, thanks for the reference


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    This post first appeared at Oracleinaction  ( Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
    NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now