Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8224693
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T15:09:38+00:00 2026-06-07T15:09:38+00:00

I have a need to execute a batch file when I drop it into

  • 0

I have a need to execute a batch file when I drop it into a specific folder of one of my Windows PCs.

We have 20 PCs spread out thruout the US. I can remote into each PC and execute the batch file on the local PC but that takes a long time.

I can also do a file transfer into each of these PCs very quickly. If I can get the batch file to execute once it is placed in a specific folder that would solve my problem.

I’ve heard of listeners in the past. Where “something” on the PC is just looking at the contents of a folder. If a file happens to exist in that folder the listener executes “something”.

Here’s some pseudocode to help get a better understanding:

\\Program watches the contents of C:\Folder1
If 
   file batchfile.bat exists in C:\Folder1
     then execute batchfile.bat and then delete batchfile.bat

Else
   continue watching C:\Folder1 for batchfile.bat

I’m digging around SO and looks like PowerShell is going to be the path I need to take. Do you guys agree or is there a more efficient solution?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T15:09:40+00:00Added an answer on June 7, 2026 at 3:09 pm

    Here’s how I’d do it:

    param([switch]$install)
    
    $batchfile = "C:\Folder1\batchfile.bat"
    
    if($install)
    {
        invoke-expression ("schtasks -create -tn `"Job1`" -tr `"powershell -file '" + $myinvocation.mycommand.path + "'`" -sc DAILY -st 05:00 -rl HIGHEST -ru SYSTEM")
    }
    else
    {
        if(test-path $batchfile)
        {
            cmd /c batchfile.bat
            remove-item $batchfile | out-null
        }
    }
    

    Run the above script with the “-install” switch and it will create a scheduled task to run once a day at 5:00am. If you’d like it to run more often check the syntax for schtasks to change that.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two .exe file and 3 windows batch files and i need to
I have a script that I need to execute using a batch file. Do
I have a batch file that I need to run within my NSIS installer.
I have a stored proc that I need to execute 100 times (one for
I need some help in writing a batch file. I have a path stored
I have two lines of call command in batch file like this: call execute.cmd
I have a batch file to execute a VB script. While executing the batch
I have a need to allow my users to execute .NET code that they
I have a bash script which need to execute some php scripts and to
I have a query that I need to execute that I do not know

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.