Friday, May 25, 2012

Windows TASK creation automatically

SCHTASKS

Create, delete, edit, list, start or stop a scheduled task.
Works on local or remote computers.
Syntax:

   SCHTASKS /Create [Connect_Options] Create_Options /TN taskname

   SCHTASKS /Delete [Connect_Options] /TN taskname [/F]

   SCHTASKS /Query  [Connect_Options] [/FO format] [/NH] [/V]

   SCHTASKS /Run [Connect_Options] /TN taskname

   SCHTASKS /End [Connect_Options] /TN taskname

   SCHTASKS /Change [Connect_Options] {[/RU username] [/RP password] [/TR taskrun]} /TN taskname

 Connect_Options:
     /S system                      # Remote system (default is local)
    [/U username [/P password]]     # Submit job under this name

 Create_Options:
    /TR taskrun                     # Pathname of the executable to run
    /ST starttime                   # HH:MM:SS (24 hour)
    [/RU username [/RP password]]   # Run job as this user
    /SC schedule [/MO modifier]     # When to run, see below
    [/D day]                        # Day = MON,TUE,WED,THU,FRI,SAT,SUN
    [/M months]                     # Month=JAN,FEB,MAR,APR,MAY,JUN,JUL,AUG,SEP,OCT,NOV,DEC.
    [/I idletime]                   # 1 - 999 minutes (ONIDLE task only)
    [/SD startdate] [/ED enddate]   # Start and end date "dd/mm/yyyy"

 options:
    /TN   A name for the task
    /F    Force delete, ignore warnings even if the task is currently runnning.
    /FO   Output format: TABLE, LIST, CSV
    /NH   No header
    /V    Verbose output
Notes:
For MONTHLY schedules give the DAY as a number 1 - 31 (default=1)

To prompt for the password, specify /RP * or /RP none
The User Account under which the Schedule service runs may require specific file access permissions, user permissions and drive mappings.
If the /RU username and /RP Password parameters match the currently logged-in user, the task will run interactively (visible in the foreground).

For the system account, /RU username can be written as "", "NT AUTHORITY\SYSTEM" or "SYSTEM", a Password is not required. The system account has full access to the local machine but has no permissions on any other machines (or mapped drives) across the Network.
/SC schedule  The schedule frequency.
Valid schedules: MINUTE,HOURLY,DAILY,WEEKLY,MONTHLY, ONCE,ONSTART,ONLOGON,ONIDLE.

/MO modifiers allow finer control:

    MINUTE:  1 - 1439 minutes.
    HOURLY:  1 - 23 hours.
    DAILY:   1 - 365 days.
    WEEKLY:  1 - 52 weeks.
    ONCE:    No modifiers.
    ONSTART: No modifiers.
    ONLOGON: No modifiers.
    ONIDLE:  No modifiers.
    MONTHLY: 1 - 12, or FIRST, SECOND, THIRD, FOURTH, LAST, LASTDAY.
Power Saving
The property for "Wake up the machine to run this task" cannot be set using schtasks, but this property is essential if you need the task to run on a machine that has PowerSaving enabled.
To work around this, create a task on one computer using the control panel GUI. This will create a .job file in C:\%windir%\Tasks\
To replicate the scheduled task onto other machines copy the .JOB file to C:\%windir%\Tasks on each machine.

This techique will not retain any system account credentials, so if you need to run the tasks under System, run the following after copying the .JOB file:
SCHTASKS /CHANGE /RU "NT Authority\System" /TN "Yourtaskname"
Examples:
Create a task to run at 11 pm every weekday
SCHTASKS /Create /SC weekly /D MON,TUE,WED,THU,FRI /TN MyDailyBackup /ST 23:00:00 /TR c:\backup.cmd /RU MyDomain\MyLogin /RP MyPassword
Now delete the task:
SCHTASKS /Delete /TN "MyDailyBackup" /f
Create a daily task to run a script at 5 pm:
SCHTASKS /create /tn "My Script" /tr "\"c:\my folder\script.cmd\" arguments" /sc daily /sd 12/29/2008 /st 17:00
Task Scheduler options are stored in the registry
HKLM\SOFTWARE\Microsoft\SchedulingAgent\

Wednesday, May 16, 2012

PHP Functional testing selenium

Sample for selenium settings -

down selenium RC channel from the selenium.org. Place it in same PHP folder for better faster/access. Run the command
CMD> java   -jar   YOUR SELENIUM JAR FILE PATH

now you are done server is running. Change the WebTestCase.php or your php file for proper linking. Run the command

cmd> phpunit functional/yourtest.php

if you find some issues with browser linking do the following in the phpunit.xml or your config file

    <selenium>
        <browser name="Internet Explorer" browser="*iexplore" ></browser>
        <browser name="Firefox" browser="*firefox C:\Program Files\Mozilla Firefox 4.0 Beta 10\firefox.exe" />
        <browser name="Google Chrome" browser="*googlechrome C:\Program Files\Google\Chrome\Application\chrome.exe" />
    </selenium>


by above way you can add any browser using * (Asterisk) in the front and then full path.


;) enjoy

YII Unit test troubleshooting FATA ERROR : Class not found Error

Recently i started using YII Framework, its so amazing. While using unit tests i found some issues and wasted a lot of time for tuning it. Here is my observations which worked at the end on WINDOWS machine -


ASSUMPTIONS -
a) you have pear installed
b) PHP xdebug installed [pls follow my other post http://usemytips.blogspot.it/2012/05/php-xdebug-installation-simplest-method.html ]




Lets start the magic -


STEP 1 --------------------------------


UPDATE PEAR - using your command prompt update PEAR 


 cmd> pear channel-update pear.php.net


 cmd> pear list-upgrade




now for all upgrades listed above follow the upgrades by using command 


cmd> pear install -f pear.php.net/XXXX    [where XXXX is upgrade name listed from above command for example if pear upgrade is needed the command will become 


cmd> pear install -f pear.php.net/PEAR




STEP 2 --------------------------------


UPDATE/INSTALL PHPUNIT - using your command prompt update/install phpunit 


[UPGRADE]
 cmd> pear channel-update pear.phpunit.de


 cmd> pear list-upgrade


[INSTALL]
cmd> pear install -f  pear.phpunit.de /PHPUnit    




OK, now you have installed phpunit, updated Pear libs, and hopefully x-debug working well. All are PHP version dependent so make sure that they are compatible.


STEP 3 ------check your PHP.ini for include_path, it must have the pear/phpunit pointers in it. like 


include_path="C:\php;c:\php\pear;C:\php\pear\phpunit"






 STEP 3 ---------------------YII integration-----------


make sure that your /protected/tests/bootstrap.php has all file pointers set to locate yiii.php. from your command prompt locate the tests folder -


cmd > cd C:\YOUR YII ROOT\YOUR WEB APP\protected\tests  [ENTER]


C:\YOUR YII ROOT\YOUR WEB APP\protected\tests> php unit/DbTest.php   [ENTER]




 remember php bold and large is for php command [location of php.exe]. If someone have different directory structure installation it can be 


C:\YOUR YII ROOT\YOUR WEB APP\protected\tests> YOURDRIVE\PHP EXEPATH  unit\DbTest.php  




[NOTE - If you get error that php is not a suffix for php.exe just run a command in php


CMD>pear   config-set    php_suffix   .exe

PHP Xdebug installation - Simplest method




When we try to install X-Debug manytimes its troublesome. Here is the simple solution

Win7 - Installation 
Assuming you have PHP installed and updated. If possible update it, or just check your version using your command prompt

CMD>YOURPARH TO PHP>php -version

This will show you which version of PHP you have installed with other details.

Now create a php info file in Webroot (Localhost / provider webroot)  as follows [saving it wtih filename check.php]
<?php
phpinfo();
?>

Run this file from your web server - YOURHOST[:PORT]/check.php?
COPY the output of this page [Simple CTRL+C]

go to http://xdebug.org/wizard.php? 
and paste in the box. Click on Analyse my phpinfo() output. This page will give you the instructions to follow for the xdebug installation.[for simplicity name the php_xdebug-VCX-xxx.dll to php_xdebug.dll]

NOTE - in PHP.ini please comment
extension=php_xdebug.dll
and put
zend_extension=php_xdebug.dll

if you RUN again php-version from command prompt it will show php details with Xdebug version too.