Windows 7 Forums

Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: Schtasks not working properly, Windows 7

22 Oct 2012   #1
neone

Windows 7 Ultimate x64
 
 
Schtasks not working properly, Windows 7

Hi, I am making batch file program which monitors computer tasklist, openfiles and system variables every x minutes.

This is my scheduled bat file, ks1.bat, which outputs openfiles to txt file:
Code:
@echo off
cd..
cd results
md %date%
cd %date%
echo Computer detective is running...
echo.
echo Copying active files list...
openfiles > Active_Files_List.txt
echo Task completed. Detective closes...
ping -n 3 127.0.0.1 >nul
exit
This is line in main batch which shedules to run this file:
Code:
cd ComputerDetective
cd Tasks
schtasks /create /sc minute /mo %minutes% /tn "Computer detective" /tr ks1.bat
Problem is when ks1.bat is scheduled to run from main program, I see only ks1 cmd window splash and no commands are done. I also tried to schedule ks1 from desktop including full path, but then I get two lines which say The system cannot find the path specified and file or directory already exists.

Please help me to solve this problem. Sorry for my bad english if it's so, I am from Lithuania. Thank you in advance.


My System SpecsSystem Spec
.
22 Oct 2012   #2
Ztruker

Windows 10 Pro X64
 
 

What is %minutes% set to?

I think you need to specify the full path to ks1.bat.

/tr "c:\users\********\ks1.bat"

Also, openfiles requires one or more parameters, something like this works for me:

openfiles /query /s \\computername /v
My System SpecsSystem Spec
22 Oct 2012   #3
neone

Windows 7 Ultimate x64
 
 

%minutes% is set to user entered minutes. I want to avoid full path to ks1, because this program will be used in another computers. I'll try your suggestion with parameters tomorrow. Thanks
My System SpecsSystem Spec
.

23 Oct 2012   #4
neone

Windows 7 Ultimate x64
 
 

Tried to specify full path, still ks1 says that cannot find path and that %date% directory exists, even if it isn't. Added parameter /query to openfiles, no changes. Ks1 works perfectly only when I run it by double-clicking on it. It creates subfolder %date% in folder results and outputs openfiles /query to Active_Files_List.txt

Tried to edit ks1.bat
Code:
@echo off
REM cd..
REM cd results
REM md %date%
REM cd %date%
echo Computer detective is running...
echo.
echo Copying active files list...
openfiles /query > Active_Files_List.txt
echo Task completed. Detective closes...
ping -n 3 127.0.0.1 >nul
exit
When I run it, it creates txt and outputs openfiles, but scheduled from cmd with full path it doesn't.

This is my schtasks line when i try to schedule from cmd:
Code:
schtasks /create /sc minute /mo 1 /tn "Computer Detective" /tr C:\Users\*****\Desktop\OSND\ComputerDetective\tasks\ks1.bat
My System SpecsSystem Spec
23 Oct 2012   #5
neone

Windows 7 Ultimate x64
 
 

Now I noticed that when ks1 says cannot find path specified, it creates %date% folder and txt with openfiles in C:/Windows, but path is correct..
My System SpecsSystem Spec
23 Oct 2012   #6
Ztruker

Windows 10 Pro X64
 
 

Where is ks1.bat running from?
My System SpecsSystem Spec
24 Oct 2012   #7
neone

Windows 7 Ultimate x64
 
 

From C:\Users\*****\Desktop\OSND\ComputerDetective\tasks\ks1.bat

ks1.bat:
Code:
@echo off
cd..
cd results
md %date%
cd %date%
echo Computer detective is running...
echo.
echo Copying active files list...
openfiles /query > Active_Files_List.txt
echo Task completed. Computer detective closes...
ping -n 3 127.0.0.1 >nul
exit
My System SpecsSystem Spec
24 Oct 2012   #8
Ztruker

Windows 10 Pro X64
 
 

Is there a results folder under C:\Users\*****\Desktop\OSND\ComputerDetective?

cd..
cd results

expects it to be there.
My System SpecsSystem Spec
25 Oct 2012   #9
neone

Windows 7 Ultimate x64
 
 

Yes, it is there
My System SpecsSystem Spec
25 Oct 2012   #10
neone

Windows 7 Ultimate x64
 
 

No ideas, why ks1 cannot find that path cd.. cd results I tried everything
My System SpecsSystem Spec
Reply

 Schtasks not working properly, Windows 7




Thread Tools Search this Thread
Search this Thread:

Advanced Search




Similar help and support threads
Thread Forum
Windows Explorer is not working properly.
Hi everybody. Dr. Nick I have a problem for about 1 month, and i haven't got rid of it. When I start Windows 7, it works fine for a random time (it can be 15 minutes, it can be 5 hours) But when it happens, i get this when I do some actions like Opening "Computer": Picture 1 Opening...
General Discussion
Browsers not working properly on windows 7
I have two problems. when I use internet explorer, it constantly flickers, especialy during videos. When I use google chrome it doesn't flicker but youtube freezes up
Browsers & Mail
windows not working properly
Installed Windows 7 on a new build-ssd. Windows loaded and worked properly, and was able to access anything I tried to. Installed driver for graphics card. After restart, windows shows desktop background. No icons and unable to open start menu from windows key. I am able to right click...
BSOD Help and Support
My Windows Explorer is not working properly
I'm using windows 7 ultimate version 6.1 ,wen i start my computer it logon but after nothing is displayed, only blank screen is displayed. but i can operate the system via task manager, for ex:to open the logical drive i wil press ctrl+alt+del ->taskmanager->new task->run->e: ,then my logical drive...
BSOD Help and Support
9500GT not working properly in Windows 7?
I am coming to Windows 7 from Vista 64bit Ultimate. On Vista I was able to get aero enabled and my system scored a 4.7 on the winsat tests. When I did a clean install and went to Windows 7 Ultimate 64bit, my aero doesn't want to initiate. I also cannot complete my winsat test because when it...
Graphic Cards


Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 07:10.

Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App