Live Chat & Podcast at 1:00PM Eastern on Sunday!
There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
Search
All Other Software
Tag Cloud
access acer asus bios bsod computer crash desktop driver drivers error ethernet excel freeze gaming hard drive hardware hdmi internet laptop malware memory modem monitor motherboard network printer problem ram registry router security slow software sound toshiba trojan ubuntu 11.10 uninstall usb video virus vista wifi windows windows 7 windows 7 32 bit windows 7 64 bit windows xp wireless
Search
Search for:
Tech Support Guy Forums > Software & Hardware > All Other Software >
Solved: Launch a program based on folder

Reply  
Thread Tools
cojast08's Avatar
Junior Member with 4 posts.
 
Join Date: Nov 2008
Experience: Intermediate
09-Feb-2010, 04:29 PM #1
Solved: Launch a program based on folder
I hope this is doable, so here it goes.

I have created a .bat file that i want to launch everytime a file or folder gets created or modified inside c:\monitor.

I assume the only way this is possible is to creat a service that runs and monitors the folder...but i have no clue. I am looking for any input or ideas on how to do this or if it is possible.

Thank you
Squashman's Avatar
Trusted Advisor with 18,706 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
Experience: Bocks of Rox
09-Feb-2010, 04:51 PM #2
What does the batch file do?
There are plenty of free programs out there to monitor file and folder changes but I am not sure if they will launch a batch file.
http://www.technixupdate.com/7-free-...older-changes/
TheOutcaste's Avatar
Computer Specs
Distinguished Member with 9,048 posts.
 
Join Date: Aug 2007
Location: Oregon, USA
Experience: Intermediate
09-Feb-2010, 04:58 PM #3
Couple more programs in this post, as well as links to VBScripts to monitor a folder:
http://forums.techguy.org/7147860-post4.html
cojast08's Avatar
Junior Member with 4 posts.
 
Join Date: Nov 2008
Experience: Intermediate
09-Feb-2010, 05:05 PM #4
Currently the .bat file just calls another program to run but i will be adding more stuff to it.
I basically just am trying to get the monitor part working first to recognize the change then call the .bat file everything after that is a breeze.
TheOutcaste's Avatar
Computer Specs
Distinguished Member with 9,048 posts.
 
Join Date: Aug 2007
Location: Oregon, USA
Experience: Intermediate
09-Feb-2010, 05:49 PM #5
This will monitor a directory tree for changes.
Set the interval to check the tree in the Set _Delay line. The value is in seconds.
Code:
@Echo Off
Set _Delay=10
Set _Folder=E:\Scripts
Set _Base=%temp%\BaselineState.dir
Set _Chck=%temp%\ChkState.dir
Set _OS=6
Ver|Findstr /I /C:"Version 5">Nul
If %Errorlevel%==0 Set _OS=5 & Set /A _Delay=_Delay*1000
:_StartMon
Call :_SetBaseline "%_Base%" "%_Folder%"
:_MonLoop
If %_OS%==5 (Ping 1.0.0.0 -n 1 -w %_Delay%>Nul) Else Timeout %_Delay%>Nul
Call :_SetBaseline "%_Chck%" "%_Folder%"
FC /A /L "%_Base%" "%_Chck%">Nul
If %ErrorLevel%==0 Goto _MonLoop
::
:: Insert code to run when a change occurs
::
Goto :_StartMon

:::::::::::::::::::::::::::::::::::::::::::::::::::
:: Subroutine
:::::::::::::::::::::::::::::::::::::::::::::::::::
:_SetBaseline
>"%~1" Dir /S "%~2"
Goto :EOF

Last edited by TheOutcaste; 10-Feb-2010 at 09:57 AM..
cojast08's Avatar
Junior Member with 4 posts.
 
Join Date: Nov 2008
Experience: Intermediate
10-Feb-2010, 07:54 AM #6
Thank you i think that code will work for what i am looking for.
Reply

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.
Thread Tools



Facebook Facebook Twitter Twitter TechGuy.tv TechGuy.tv Mobile TSG Mobile
You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 11:35 PM.
Copyright © 1996 - 2011 TechGuy, Inc. All rights reserved.

Powered by Cermak Technologies, Inc.