2

So I tried and tried but couldn't figure out this one for some reason.

how can I run a task from a desired directory instead of System32 directory where cmd.exe is. so, when I schedule a task and try to run it ..

command prompt suppose to go to "c:\users\aaa\bbb\ccc" and then pass the argument.

Instead, It's starts at c:\Windows\System32 and fails.

Could anybody help me with this please?

I really appreciate it.

Thank you.

EDIT --

so, now I have a run.bat file with following content in it ...

 C:\Users\aaa\bbb\ccc\dd (location to my testrunner.bat file) 
 testrunner.bat Scripts/all.suite website-address ie (command for the task I wanna perform)

 net stop schedule (since window is poping up and going away way to fast, I added this to stop it (not working))
shellter
  • 36,525
  • 7
  • 83
  • 90
  • @shelter - Thank you very much for your reply. I tried that but nothing really happened. This is what my .bat file look like. C:\Users\aaa\bbb\ccc\dd testrunner.bat Scripts/all.suite https://website-address ie – irvineman0406 Aug 28 '14 at 23:26
  • sorry about that ... Editing now – irvineman0406 Aug 29 '14 at 00:53

1 Answers1

1
 type run.bat

 @echo off
 cd C:\Users\aaa\bbb\ccc\dd
 rem this will show all files in dir 
 rem is the file you're expecting listed?
 dir 

 rem notice how you can make comments with a leading rem(ark)

 @echo starting scripts\all.suite
 rem you have to change this to have the full path using Windows X:\dir\dir conventions
 c:\home\Scripts\all.suite website-address
 @echo done running scripts\all.suite website-address

 @echo shutting down
 net stop schedule

So its still not clear exactly to me your goal. The reason I added the cd c:\... command is that will **C**hange **D**irectory to the path specified.

This is what you need so you can "run a task from a desired directory instead of System32".

Copy everything from the first @echo off to the last net stop and using notepad, paste it into a file, fix command names and paths website-urls, etc, then save that file to c:\temp\testrunner.bat.

Open a cmd.exe window and test that the script works. Just paste c:\temp\testrunner.bat on to cmd-line and hit enter. If that works, then made an entry in the scheduler to run c:\temp\testrunner.bat . I don't know the specifics of running a script for scheduler, so look for clues on the input screen. Is the an option to run 'now'?

If the .bat file doesn't work from the command-line, then you have to fix the file before you try running it in the scheduler. As your command Scripts/all.suite website-address is a little vague, you'll do better to post a new question asking for help to fix the .bat file and use a sample command that people will be able to use on their PCs at home.

IHTH.

shellter
  • 36,525
  • 7
  • 83
  • 90
  • Thank you very much, Took me a while to figure it out and make it work on my machine but it worked. I learned something today. – irvineman0406 Aug 29 '14 at 17:08
  • Very glad that helped and that it fostered some learning! Note for future questions, a general form is 1. I have this data (or problem), 2. I want to change the data to look like this (or solve the problem to look like X). 3. Here is the code I have tried so far. 4. Here are error messages I'm getting AND/OR here is the current output (or result). 5. Here are my thoughts about why it is not working. ALSO, you please use the formatting tool at the top left of the input box `{}`. Select your code wit mouse, click `{}` and the input box will correctly format the code to be displayed. Good luck! – shellter Aug 29 '14 at 17:58