Posts Tagged Windows

VB Script to automate unzipping files in Windows System

The following VB Script can be used to automate unzipping zip files in Windows OS.

sub unzipfile(zipfile)
	'The location of the zip file.
	ZipFile= ".\" & zipfile & ".zip"
	'The folder the contents should be extracted to.
	ExtractTo=".\" & zipfile

	'If the extraction location does not exist create it.
	Set fso = CreateObject("Scripting.FileSystemObject")
	If fso.FolderExists(ExtractTo) Then 
		fso.DeleteFolder ExtractTo
		fso.CreateFolder(ExtractTo)
	end if 
	'If NOT fso.FolderExists(ExtractTo) Then
	'   fso.CreateFolder(ExtractTo)
	'End If

	' the following two lines are required to expand the relative path to absolute path
	' otherwise, an error message will pop up and say "object is required"
	sSourceFile = fso.GetAbsolutePathName(ZipFile)
	sTargetDir = fso.GetAbsolutePathName(ExtractTo)

	'Extract the contants of the zip file.
	set objShell = CreateObject("Shell.Application")
	set FilesInZip=objShell.NameSpace(sSourceFile).items
    objShell.NameSpace(sTargetDir).CopyHere(FilesInZip)
	Set fso = Nothing
	Set objShell = Nothing
end sub
Share

Tags: , , ,

Set a program run as administrator permanently in Windows 7

There are times that you need run an application by using administrator’s privilege in Windows. To do that, the simplest way is right-clicking the application and choose “Run as administrator” in the context menu. However, it is not convenient that you want run application as administrator all the times. Here provide a couple of tips to help you set an application run as administrator permanently.

1) Application

Right click an executable application and a context menu popup. Clcik “Properties” in the menu, a dialog similar to the following will show up. Switch to “Compatibility” tab and select “Run the program as an administrator” at the bottom of the dialog window. Click “Apply” button. You are good to go.

2) Shortcut

Right-click a shortcut, a similar dialog window will show up. In the “Shortcut” tab, click “Advance” button, another dialog will popup.

In this simple window, select “Run as administrator” and click “Ok”. You are set to go.

Through the above to method, you can set a program or a shortcut always run as administrator. That same your time and make life easier.

Enjoy the tip.

Share

Tags: , , , , ,

Use Terminal Service Client of the Ubuntu System

Terminal Service Client is the tool for you to connect to your Windows computer on Ubuntu system. It provides a powerful set of functions for the Windows remote desktop. There are other related applications, Remote Desktop and Remote Desktop viewer, for Ubuntu Linux machines. Here is a brief introduction of the Terminal Service Client.

First of all, in the General tab, you should enter the ip address of the remote Windows computer. In this case, it is 192.168.2.4. And the default protocol, RDP, works perfectly for my case.

Before you click the Connect button, switch to Display tab (see the following screen shot), select “Operate in full screen mode” in the Remote Desktop Size option area. That will give you the best experience in Ubuntu environment for the Remote Desktop service.

Then click the Connect button to connect to remote computer. The first time, I was in the wonderful screen, I did not know how to exit the remote desktop and back to my Ubuntu environment. To your convenience, click Windows “Start” button at the bottom left corner, go to normal shutdown button location, you can find a button called “Disconnect”. That is the one you want to use to quit the remote desktop.

Share

Tags: , , , ,

Install Chinese support for Ubuntu 10.04 TLS Desktop

Ubuntu Desktop is an excellent desktop operating system. It can replace Windows completely with benefits, like less virus and malicious adwares and thousands of free software. Because of these benefit, I completely switched from Windows OS to Ubuntu OS with no costs and less worries. In default, Ubuntu support all sorts of languages, it is a true multi-language OS. After I complete the Ubuntu Desktop installation with English language as default, I installed Chinese language support components. It is straight forward and easy. Because the process involved a few different components, I’d like to document this process as a reference for the future.

1. Install language support

To view and input Chinese characters, you have to install Chinese language support. Select System->Administration->Language supoort to open the dialog window. Then click Install/Remove Language button to open the language selection list and scroll up and down to fine Chinese (simplified) and check Installed box at the right hand side. Then click Apply Changes. Another dialog window will pop up and the relevant components will be installed. It will take a while to install them based on your internet connection.

Once the components are installed, the Language for menus and windows list will look like the following. You can see “汉语” and “汉语(中国)” in the list.

In order to input Chinese to the applications, you have to select “Keyboard input method system”. Click the drop down list and select “ibus” as the method like the following.

2. Setup keyboard preferences

After the step 1 is done correctly, we can add Chinese input method and change the order of the input method. Click the Select an input method dropdown list and find Chinese input method and selct “Chinese – Pinyin” method, add it to the Input Method list. Then select it and move it up to the top.

Then switch to the General tab and check “Show icon in System tray”.  After this is done, you should see a small keyboard icon on the top right system tray. Click the icon, you may not see the Chinese input method, just select “Restart” and all selected input methods will show correctly.

Once the system is running correctly, you can simply use Ctrl + Space to switch language input method back and forth. It is much nicer than Windows. I really like it.

3. Other settings

After I completed the Chinese language setup, I explored the system function a little bit and find interesting function in Keyboard Shortcut. Even though I did not like Window in total, but I have used to a few functions it provides. One of these functions is “Window key+ E” to open the Window Explorer to walk through folders. It is pretty easy to setup the keyboard shortcut to achieve this. Click System -> Preferences -> Keyboard Shortcuts to open the dialog window. Scroll down the shortcut list and find the “Home Folder”. Simply select Home Folder item, press the keyboard shortcut combination. You are set. It is simple, isn’t it?

 

Share

Tags: , , , , , , , ,

PERL processes files and related functions

Command line parameters

If you want to know how many command line arguments the program gets, you can use $#ARGV because ARGV is an predefined array in Perl. Here is code snippet to use this array.


if ($#ARGV != 1)
{
print "Usage: you have provide two inputs";
exit;
}
my $mypath = $ARGV[0];

Change folder

It is as simple as simply use cd command in OS.

chdir($mypath) || die "$!";

When you use folder path in the PERL variable, please remember use \\ in DOS or Windows system to represent path, for example “.\\temp\\” represent the subfolder “temp” in the current folder. Otherwise you will get very strange errors when you run the PERL script.

Read the whole content in a file

The key command is “local $/=undef;”. See the code snippet to learn the detail.


open(DATA, "< $filename")
|| die "Failed to open the file $filename\n$!\n";

local $/ = undef;
my $content = <DATA>;

close(DATA);

Process text content

After you read the whole content in a file to a variable, you have to process it. If you have to process it line by line, you can use split function to break them into an array, like the following.


my @lines = split(/\n/,$content);

If you want to get rid of the first line, you can use the following command to achieve it.

shift(@lines);

If you want to break the content in one line by space, you can use the following command.

my @temps = split(/\s+/,$temp);

The key is the regular expression \s+, which stands for one or more space.

Share

Tags: , , , ,