Archive for the ‘Windows’ category

Using powershell on Windows

December 6th, 2011

Powershell on windows is the same thing as Bash in linux.

Set the prowershell enviroment

The prowershell script file .ps1 is defaultly forbidden to execute with the ExecutionPolicy “Ristricted”. To see your current ExecutionPolicy, open a powershell windown and type:
Get-ExecutionPolicy

There are totally 4 levels of ExecutionPolicy:

  1. Restricted: no .ps1 execution is allowed
  2. AllSigned: .ps1 files can run, but need a signed digital signature. No matter they are written locally or downloaded form Internet.
  3. RemoteSigned: Local .ps1 files can run, but downloaded scripts need a digital signature.
  4. Unrestricted: All scripts can run without digital signature.
  5. Normally, we need to run local scripts, so we set it to “RemoteSigned”:
    Set-ExecutionPolicy remoteSigned -Scope CurrentUser
    With “-Scope CurrentUser”, the ExecutionPolicy will only be changed to the logged user.

    Basics

    Loops

    There are many ways to loop in powershell: do…while…, while(){}, for(){}, …
    Here is an example of while{} loop

    $i = 1
    while ($i -le 5) {
    	Write-Host $i; # write on console
    	mkdirdir x$i # create a folder
    	
    	$i++
    } 

solve the problem of no output in console on windows eclipse with MinGW

October 14th, 2011

If you are experiencing the problem of no output in console on windows eclipse with MinGW, here is the solution.

And actually the solution the is very simple, you only have to add a PATH variable to your MinGW bin directory in the run configuration.

Here are the steps:

From menu: Run -> Run Configuration…, open the run configuration window, and add the PATH variable to your MinGW bin directory (as shown in the picture below).

Windows 7 cannot find a specific wireless network

September 18th, 2011

After an accidently reboot of the router, my win 7 laptop could not find this wireless network anymore. I tried to reboot the router and my computer. But either worked. All the other computers (and phones) can find this network and connect to it. And this computer can found other wireless networks and connect to them, but just not this. I also tried adding this network manually, however without luck. Searching on the internet didn’t give me any clue either.

Finally I thought reinstalling the network adapter’s driver might work. So I went to Device Manager, found the adaptoer, and updated the driver software. Bingo! It worked! Thank god, I don’t have to use someone else’s weak unsecured wireless network any more.

How to install MemCache on Windows 7 X64 for PHP with WAMP

August 22nd, 2011

Basics

The memcache sonsists of 2 parts: the server MemCached and the client MemCache.

  • MemCached is the cache server, the same as Mysqld (mysql server), which save and feed cache to clients.
  • MemCache is a client. With php, we need to install it as a mod, just the same as pdo_mysql (php_pdo_mysql.dll on windows).

Install MemCached

  • Download memcached from http://code.jellycan.com/memcached/ (get the win32 binary version). Here we suppose you extract the memcached in d:\memcached\.
  • If you are on Sindows Vista/7, rightclick on memcached.exe and select Properties; click on the Compatibility tab. At the bottom you’ll see Privilege Level, check “Run this program as an administrator”.
  • Open the command line by Win + R (or Start -> All Programs -> Accessories -> Command Prompt), and then run: d:\memcached\memcached.exe -d install to install the service.
  • Still in the command line, run d:\memcached\memcached.exe -d start, or net start "memcached Server" to start the service.
  • Check whether the service is running. Open Windows Task Manager, go to Services tab, you should find status of “memcached server” is “Running”.

Install MemCache php module

Note

  • To change MemCached memory size (default is 64mb), go to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\memcached Server in your registry, find the ImagePath entry and change it to:
    “C:\memcached\memcached.exe” -d runservice -m 512
  • More details see: memcached -help