kill a Windows process

from http://www.tech-recipes.com/rx/446/xp_kill_windows_process_command_line_taskkill/

The ability to perform tasks from a system’s command line allows those tasks to be used in batch files. This recipe describes several uses of taskkill to terminate Windows processes.

If you know the name of a process to kill, for example notepad.exe, use the following command from a command prompt to end it:

taskkill /IM notepad.exe

This will cause the program to terminate gracefully, asking for confirmation if there are unsaved changes. To forcefully kill the same process, add the /F option to the command line. Be careful with the /F option as it will terminate all matching processes without confirmation.

To kill a single instance of a process, specify its process id (PID). For example, if the desired process has a PID of 827, use the following command to kill it:

taskkill /PID 827

Using filters, a variety of different patterns can be used to specify the processes to kill. For example, the following filter syntax will forcefully kill all processes owned by the user Quinn:

taskkill /F /FI "USERNAME eq Quinn"

The following table shows the available filters and their use.

Filter Name  Valid Operators Valid Value(s)
-----------  --------------- --------------
STATUS        eq ne RUNNING | NOT RESPONDING
IMAGENAME     eq ne Image name
PID           eq ne gt lt ge le PID value
SESSION       eq ne gt lt ge le Session number.
CPUTIME       eq ne gt lt ge le CPU time in the format of hh:mm:ss.
MEMUSAGE      eq ne gt lt ge le Memory usage in KB
USERNAME      eq ne User name in [domain\]user format
MODULES       eq ne DLL name
SERVICES      eq ne Service name
WINDOWTITLE   eq ne Window title

eq: equals ne: not equal
gt: greater than lt: less than
gt: greater than or equal le: less than or equal

張貼在 未分類 | 發表留言

新增EXE至 Windows Service(服務)

就以這個為例子來增加Service,指令語法如下

   sc create <name>
      binpath= “c:\svn\bin\svnserve.exe –service <svn-args>"
      displayname= “Subversion Repository"
      depend= Tcpip刪除Service的指令如下

sc delete svnservice

當然還可以用regedit進去修改

位置如下

HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services

請小心修改,因為只要動到這邊都有點危險,除非你有把握不然還是不要亂刪

張貼在 未分類 | 發表留言

Hello world! 哈囉!

Welcome to WordPress.com. This is your first post. Edit or delete it and start blogging!

張貼在 未分類 | 1 則迴響

FreeBSD安裝JDK

FreeBSD安裝JDK( http://hi.baidu.com/logicbaby/blog/item/ccc61dc72d49cfdfd10060e5.html )
     以前老是以為在FreeBSD上安裝java是件很麻煩的事兒,就光是看網上說的編譯java需要n個小時都嚇的夠嗆,其實遠沒有那麼麻煩,直接下載幾個包就搞定 :)
     首先下載diablo-jdk-freebsd6.i386.1.5.0.07.01.tbz
     需要依賴以下幾個包
expat-2.0.0_1
fontconfig-2.3.2_6,1
freetype2-2.2.1_1
libdrm-2.0.2
pkg-config-0.21
xorg-libraries-6.9.0
javavmwrapper-2.3   主要是這個包需要安裝,其他的可能都安裝了的
ompat7x-i386.tbz
 : : : :如果聯網了的話可以直接這樣
# setenv PACKAGESITE ftp://ftp.freebsdchina.org/pub/FreeBSD/ports/i386/packages-8-stable/Latest/
# pkg_add -r expat
# pkg_add -r freetype
# pkg_add -r fontconfig
# pkg_add -r … 省略 …
# pkg_add -r xorg-libraries
# pkg_add -r javavmwrapper
# pkg_add -r compat7x
 
     最後也就是安裝JDK了
#pkg_add diablo-jdk-freebsd6.i386.1.5.0.07.01.tbz
好,至此你的java就可以用了。
     如果是沒有聯網,就像我這樣的,那麼可以到FreeBSDChian FTP下載上面所列的包。
     最後就是安裝了,很簡單也就是pkg_add嘛
#pkg_add expat.tbz
#pkg_add fontconfig.tbz
#pkg_add freetype2.tbz
#pkg_add libdrm.tbz
#pkg_add javavmwrapper.tbz
#pkg_add xorg-libraries-6.9.0.tbz
#pkg_add compat7x-i386.tbz
 
     最後還是安裝JDK
#pkg_add diablo-jdk-freebsd6.i386.1.5.0.07.01.tbz
     寫個HelloWord,看下裝的JDK能否正常使用
public class HelloJava{
   public static void main (String[] args){
     System.out.println ("Hello,this is my first JAVA program.");
   }
}
 
     好,go on
%javac HelloJava.java
%java HelloJava
Hello,this is my first JAVA program.
     好,至此Java安裝完畢,收工。
張貼在 Linux | 發表留言

Install Mysql Packages

#Update Your Package
yum update
 
# Install Mysql Packages
yum install mysql-server mysql mysql-devel
/etc/init.d/mysqld start
 
# By default mysql has the no passward. To change the password in command shell write the following commands
mysql
mysql> USE mysql;
mysql> UPDATE user SET Password=PASSWORD(’your_password’) WHERE user=’root’;
mysql> FLUSH PRIVILEGES;
 
# Install php and common packages
yum install php php-gd php-imap php-mysql php-pear php-xml phpxmlrpc curl libxml2 php-mbstring php-mcrypt
 
# Install VSFTP
yum install vsftpd

# Modify the conf files it depends on you.
vi /etc/vsftpd/vsftpd.conf
vi /etc/vsftpd/user_list
vi /etc/vsftpd/ftpusers
/etc/init.d/vsftpd start

 

tar xvfz phpMyAdmin-2.11.9.5-all-languages.tar.gz
mv phpMyAdmin-2.11.9.5-all-languages phpmyadmin
rm phpMyAdmin-2.11.9.5-all-languages.tar.gz
cd phpmyadmin/
cp config.sample.inc.php config.inc.php
vi config.inc.php
>> $cfg[‘blowfish_secret’] = ‘TypeAnything_for_Secure’;
vi /etc/httpd/conf.d/phpmyadmin.conf
>> Alias /phpMyAdmin /usr/share/phpmyadmin
service httpd restart
 
# Check your web-site
cd /var/www/html/
ls
cat > index.php
<?
phpinfo();
?>
 
# Setup Auto Start
setup
Select Service -> httpd, mysqld, vsftp
張貼在 Linux | 發表留言

PHP rpm的更新法

PHP rpm的更新法,2個指令就更新好了
rpm -ivh
http://repo.webtatic.com/yum/centos/5/`uname -i`/webtatic-release-5-0.noarch.rpm
yum –enablerepo=webtatic install php

 

檢查一下吧
[root@dns includes]# php -v
PHP 5.3.2 (cli) (built: Mar 5 2010 15:08:05)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
成功更新到5.3.2

張貼在 Linux | 發表留言

MIT Media Lab

張貼在 電腦和網際網路 | 發表留言

StringBuilder 或 StringBuffer

Java 1.4 或之前版本的 StringBuffer,和 5.0 版的 StringBuffer、StringBuilder 都是直接繼承自 java.lang.Object 類別。它們的作用如剛才提到的,都是為了避免字串的連接或修改時產生許多的暫存字串 (temporary strings)。但在 J2SE Documentaion 1.4.2、5.0 中都提到,StringBuffer 在多執行緒 (multiple threads) 下是安全的 (thread-safe),亦即該類別下的 method 會視需要鎖定,或稱為同步化 (synchronized) 資料處理,亦即保護程式碼不會被分割執行,多個 thread 物件會照應有順序交互執行,避免執行結果的不一致。亦即一次只有一個 thread 可以修改 StringBuffer 實體的狀態,無論你在何時修改 StringBuffer,都不用擔心會有其它的執行緒出現,中斷你正在執行的工作,而毀損了字串資料 [1],[4]:
String buffers are safe for use by multiple threads. The methods are synchronized where necessary so that all the operations on any particular instance behave as if they occur in some serial order that is consistent with the order of the method calls made by each of the individual threads involved.

 而 Java 5.0 新推出的 StringBuilder 可與 StringBuffer 相容,但不應用在同步 (synchronization) 或多重執行緒的情況。但據 Documentation 和某書 [2] 的說法,若是在單一執行緒的環境下,或一段你不擔心會有多個執行緒存取的程式碼中,或是不需同步處理的情況下,就應該儘可能地以新的 StringBuilder 替換 StringBuffer,因為在大多數的情況下,前者的運作速度都比後者要快。版工猜若非 synchronized 的話,應該也可省去一些 overhead。且聽說過去在 StringBuffer上看過的 method 在 StringBuilder 上都有,所以直接對舊有的程式碼作搜尋與替換,原則上不會有編譯上的問題 [2]。
 
張貼在 java | 發表留言

XSL Grouping 範例

 

Finding out whether a contact is first in the list returned by the key involves comparing the contact node with the node that is first in the list returned by the key. There are a couple of generic methods of testing whether two nodes are identical:

  1. compare the unique identifiers generated for the two nodes (using generate-id()):

    contact[generate-id() =
            generate-id(key('contacts-by-surname', surname)[1])]
    	  
  2. see whether a node set made up of the two nodes has one or two nodes in it – nodes can’t be repeated in a node set, so if there’s only one node in it, then they must be the same node:

    contact[count(. | key('contacts-by-surname', surname)[1]) = 1]
<xsl:key name="contacts-by-surname" match="contact" use="surname" />
<xsl:template match="records">
	<xsl:for-each select="contact[count(. | key('contacts-by-surname', surname)[1]) = 1]">
		<xsl:sort select="surname" />
		<xsl:value-of select="surname" />,<br />
		<xsl:for-each select="key('contacts-by-surname', surname)">
			<xsl:sort select="forename" />
			<xsl:value-of select="forename" /> (<xsl:value-of select="title" />)<br />
		</xsl:for-each>
	</xsl:for-each>
</xsl:template>
 
以上是範例重點:
 將以下第一個TABLE的資料轉換為第二個TABLE的顯示方式  
欠桶出貨單
出貨日期 出貨單號 送貨員工 鋼瓶類別 規格(KG) 客戶欠桶 已處理 尚欠
2009/07/09 OA0220090709003 仇如玉 標準 20 1 0 1
2009/07/14 OA0220090714001 仇如玉 標準 16 1 0 1
2009/07/14 OA0220090714001 仇如玉 標準 20 1 0 1
欠桶出貨單
出貨日期 出貨單號 送貨員工 鋼瓶類別 規格(KG) 客戶欠桶 已處理 尚欠
2009/07/09 OA0220090709003 仇如玉 標準  20  1  0  1 
2009/07/14 OA0220090714001 仇如玉 標準
標準 
16
20 
1
1 
0
0 
1
1
張貼在 XML | 發表留言

Example Java user input and output

import java.io.*;
 
class GetUserInput {

 public static void main(String[] args) {
  // the data that will be entered by the user
  String name;
  // an instance of the BufferedReader class
  // will be used to read the data

  BufferedReader reader;
  // specify the reader variable
  // to be a standard input buffer
  reader = new BufferedReader(new InputStreamReader(System.in));
  // ask the user for their name
  System.out.println("What is your name?");
  // read the data entered by the user using
  // the readLine() method of
  // the BufferedReader class
  // and store the value in the name variable

  try {
   name = reader.readLine();
   System.out.println("Your name is " + name);
  } catch (IOException e) {
   //e.printStackTrace();
   System.out.println("An unexpected error occured.");
  }
 }

}

張貼在 java | 發表留言