login script to run an exe file while logging on

Posted on 2006-03-31
Last Modified: 2012-11-12
Hi all
I am running windows server 2003 ent edition with AD.  I use 'login.bat' to install and map all the network drives.  I have an '.exe' file which I want to run while any user logs in.  How can I do that through my 'login.bat' or any other way through the AD.
Question by:amanzoor
    LVL 19

    Assisted Solution

    Hi amanzoor,

    Use the Call commmand.

    CALL C:\yourprogram.exe

    If there are spaces in the path use:

    CALL "C:\Program Files\yourprogram.exe

    LVL 95

    Assisted Solution

    by:Lee W, MVP
    Just put it in.  Have you tried that?
    LVL 5

    Accepted Solution

    in your login bat, add this line

    call c:\DIR\NOTEPAD.EXE

    of course, change c:\dir\notepad.exe to the executable you desire to run.
    LVL 4

    Assisted Solution


    Try it on test user first.

    the location server followed by the exec
    LVL 95

    Assisted Solution

    by:Lee W, MVP
    CALL is typically used for batch files - I've not see it used with EXEs.

    If the EXE is hanging the logon script because it continues to run, then use the START command -

    START yourprogram.exe


    LVL 2

    Assisted Solution

    leew is correct.

    CALL is used for batch files in batch files.  In order to use the program you would use the START command.  This will allow the program to run (like a TSR).
    LVL 18

    Assisted Solution

    by:Sam Panwar
    - Create a batch file called "netlogon.bat" in this folder:
      "c:\documents and settings\all users\start menu\programs\startup"
    - Create a batch file \\YourServer\SomeShare\login.bat
    - Put these lines into it:
      @echo off
      \\YourServer\SomeShare\psexec.exe  \\PC1 c:\Tools\SomeCommand.exe

    @echo off
    net use x: \\ace-file01\SHARED
    if exist x:\InventoryData\AceAssets\clientcon.exe
    (unwrap this line!)
    net use x: /d

    - On PC2..9, create a task under the Task Scheduler to
      invoke \\YourServer\SomeShare\login.bat.
    - Tell the Task Scheduler to run the task at logon time.

    Note that you must schedule the task under and account
    name / password that is valid on PC.

    You can get psexec.exe from's free.

    - Put the following lines into netlogon.bat:

    Other scripts sites:
    LVL 5

    Expert Comment

    leew , matricii, are correct Call would leave the logon.bat hung until the exe that was called ended all that is needed is the start c:\???.exe
    thereby ending the logon.bat after starting the exe

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Join & Write a Comment

    Suggested Solutions

    Overview This article describes how to silently install Adobe Reader on multiple workstations, customize the installation options (accept EULA, remove desktop shortcut etc) using the Adobe Customization Wizard and install Adobe Reader font packs an…
    Let’s list some of the technologies that enable smooth teleworking. 
    Viewers will learn how to connect to a wireless network using the network security key. They will also learn how to access the IP address and DNS server for connections that must be done manually. After setting up a router, find the network security…
    After creating this article (, I decided to make a video (no audio) to show you how to configure the routers and run some trace routes and pings between the 7 sites…

    733 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

    18 Experts available now in Live!

    Get 1:1 Help Now