Showing posts with label Windows. Show all posts
Showing posts with label Windows. Show all posts

Tuesday 19 December 2017

How to change Timezone in Windows from Command Line

Guys, today let us learn how to change and/or update the Timezone on Windows machines without using the GUI i.e from the command line. On most flavors of Windows, the timezone utility (tzutil.exe) lies at C:\Windows\System32 location. 

Note : Updating timezone requires a user to have administrator rights. Make sure you have it.

So now, open the command line as administrator. Open the tzutil.exe from C:\Windows\System32 location. Let us look into a few illustrations on its usage.
  • To list current time zone :
C:\Windows\System32>tzutil.exe /g
Eastern Standard Time

  • To display the list of all available time zones :
C:\Windows\System32>tzutil.exe /l

(UTC+08:00) Irkutsk
North Asia East Standard Time

(UTC+08:00) Kuala Lumpur, Singapore
Singapore Standard Time

(UTC+08:00) Perth
W. Australia Standard Time

(UTC+08:00) Taipei
Taipei Standard Time

(UTC+08:00) Ulaanbaatar
Ulaanbaatar Standard Time

(UTC+08:30) Pyongyang
North Korea Standard Time

(UTC+08:45) Eucla
Aus Central W. Standard Time

(UTC+09:00) Chita
Transbaikal Standard Time

(UTC+09:00) Osaka, Sapporo, Tokyo
Tokyo Standard Time

(UTC+09:00) Seoul
Korea Standard Time

  • To update/set the time zone to a different time zone
C:\Windows\System32>tzutil.exe /s "Cen. Australia Standard Time"

So as you see there are basically only 3 switches to use /g /l and /s

Tuesday 3 October 2017

How to get username from IP address of remote computer

On a network (Home LAN or WiFi or corporate intranet), it is possible to get username from the assigned IP address of a remote machine. Assuming you have a bunch of users using Windows machines on the same network, lets look into the windows command to get the username.

For example, type the following in command prompt :

wmic.exe /node:17.16.15.28 computersystem get username
UserName
IRONCLADZONE\Special.User

Note that this works only for the remote machines which are connected on the same network.

Saturday 20 February 2016

Ant - Build.xml example on Mac OS X

In today's post guys, we'll cover the topic of building a very simple Java based project using Apache Ant. We'll learn how to write a basic build.xml file for building it.  Let's first look into the code for build.xml and then we'll breakdown the code with the explanation.

build.xml :

<?xml version="1.0" encoding="UTF-8"?>

<project name="AntBuildTest" default="create-jar" basedir=".">

<property name="build.home" value="${basedir}" />

<target name="clean">
<delete dir="${build.home}/src" />
<delete dir="${build.home}/bin" />
<delete dir="${build.home}/lib" />
<delete dir="${build.home}/test" />
<delete dir="${build.home}/dist" />
</target>

<target name="createdir" depends="clean">
<mkdir dir="${build.home}/src" />
<mkdir dir="${build.home}/bin" />
<mkdir dir="${build.home}/lib" />
<mkdir dir="${build.home}/test" />
<mkdir dir="${build.home}/dist" />
</target>

<path id="classpath">
<pathelement location="${build.home}/bin"></pathelement>
</path>

<target name="copydir" depends="createdir">
<copydir src="/Users/ironcladzone/Documents/workspace/AntBuildTest/src"
dest="/Users/ironcladzone/Documents/workspace/AntBuildTest/build/src"> </copydir>
</target>

<target name="compile" depends="copydir">
<javac classpathref="classpath" includeantruntime="false"
srcdir="/Users/ironcladzone/Documents/workspace/AntBuildTest/build/src"
destdir="/Users/ironcladzone/Documents/workspace/AntBuildTest/build/bin"
includes="**/*.java"></javac>
</target>

<target name="create-jar" depends="compile">
<jar basedir="${build.home}/bin" destfile="${build.home}/dist/TestJar.jar"
includes="**/*.class"></jar>
</target>


</project>

Now let's look into the folder structure in the Eclipse Package Explorer :


Now, let's get down to the explanation guys :

1. First of all, AntBuildTest is my project workspace which has the source code in it.

2. Next I created a build directory under which I created the above build.xml file.

3. Now in the builds.xml I have defined various steps/tasks also known as targets viz : clean, createdir, copydir, compile, create-jar. Note that a build.xml will still successfully build even if it doesn't have a single target defined.

4. For every build.xml file, we first have to define the <project></project> tag, in which we mention the project name, basedir and default target to be executed.

5. Basedir is the location of the current root directory in which build.xml exists i.e the absolute path

6. The default target that we define, will be the task/target which will be executed. Now the target can have dependencies on other targets.

7. Note that target can have one or many dependencies on multiple targets.

8. The 'clean' target is the target to delete all sub-directories that we create in the 'createdir' target. So every time we perform a clean build, the directories created in the last build will be deleted.

9. In the 'createdir' target, we make directories namely : src, bin, lib, test, dist.

10. We now want to copy the source code from our local workspace to the 'src 'directory that we create in the 'createdir' target,. So in the 'copydir' target we define the step to copy the source code.

11. Now once we have the source code, we need to compile it right. So we define the 'compile' target wherein we define 'srcdir' i.e the location where we have our java files. Also we mention the 'destdir' as the bin folder i.e this is where we want our .class files to be saved.

12. During compilation, we need to specifically tell the xml where the .class files would be. So we need to define the classpath. 

13. We define the classpath i.e the bin directory which will have the .class files.

<pathelement location="${build.home}/bin"></pathelement>

14. After compilation, we define the 'create-jar' target, in which we create the jar package - TestJar.jar. Make sure not to miss the .jar file extension. Note that we have mentioned the include parameter for including the **/*.class files that need to be included in it.

15. We have also defined the 'destfile' parameter i.e the location where we want the jar file to be saved i.e the 'dist' directory for distribution.

16. Oh and I missed the 'lib' directory, which will basically hold the external jar files required for our project.

17. Well, I hope I covered the simple basic fundamental points surrounding an Ant build.  Let me know if I missed any point guys. If I did, I'll try to cover them in detail in an another upcoming post covering an advanced scenario. Till then, ciao!
Related Posts Plugin for WordPress, Blogger...
eXTReMe Tracker