Pages

Showing posts with label windows. Show all posts
Showing posts with label windows. Show all posts

Tuesday, March 18, 2014

How to set ORACLE_HOME in Windows Environment Variable

What is ORACLE_HOME used for?


The ORACLE_HOME is an environment variable which is used to set and define the path of Oracle Home (server) Directory.

What is ORACLE_BASE used for?

* The ORACLE_BASE is also an environment variable to define the base/root level directory where you will have the Oracle Database directory tree - ORACLE_HOME defined under the ORACLE_BASE directory. 

How to set ORACLE_HOME in Environment variable

To set the ORACLE_HOME environment variable go to My Computer -> Properties -> Advanced -> Environment Variables -> System Variables -> New/Edit/Delete.


oracle home environment variable
After setting the environment variables, open a fresh CMD tool and check whether they set properly or not. Do not try on already opened CMD tool to make sure the variables set or not.

How to check if ORACLE_HOME is set

Open cmd and type this command
C:\echo %ORACLE_HOME% 

Monday, November 18, 2013

How to upgrade evaluation version of windows server 2012

windows server 2012 standard

Most evaluation versions can be converted to full retail versions, but the method varies slightly depending on the edition. This post will discuss about How to upgrade evaluation version of windows server 2012.

Before you attempt to convert the version, verify that your server is actually running an evaluation version. To do this, do either of the following:
  1. From an elevated command prompt, run slmgr.vbs /dlv; evaluation versions will include “EVAL” in the output.
  2. From the Start screen, open Control Panel. Open System and Security, and then System. View Windows activation status in the Windows activation area of the System page. Click View details in Windows activation for more information about your Windows activation status.
  3. From an elevated command prompt, determine the current edition name with the command DISM /online /Get-CurrentEdition or DISM /online /Get-TargetEditions. Make note of the edition ID, an abbreviated form of the edition name. 
  4. Then run DISM /online /Set-Edition:<edition ID> /ProductKey:XXXXX-XXXXX-XXXXX-XXXXX-XXXXX /AcceptEula, providing the edition ID and a retail product key. The server will restart twice.

How to autoshutdown windows in spesific tiime


You can schedule task to shutdown at specific time, follow steps below to schedule autoshutdown task:

  1. Go to Start > Control Panel > System and Security > Administrative Tools and click on the Task Scheduler.
  2. From the Action menu in Task Scheduler, click "Create Basic Task..."
  3. In the "Create Basic Task Wizard" windows that pops up, Type in a title and a description. Something basic like "PC Shutdown."
  4. Click "Next."
  5. On the "Task Trigger" screen, choose the frequency with which you want the Shutdown PC to run. For nightly shutdown, click on "daily" and click the Next" button.
  6. On the "Daily" screen, enter the date and time you want your PC to shutdown. Click "Next." 
  7. On the "Action" screen, choose "Start a program" and click "Next."
  8. On the "Start a Program" screen, type C:\Windows\System32\shutdown.exe in the "Program/script" text field.
  9. In the Add arguments text field type /s.
  10. Click "Next."
  11. Confirm your settings on the Summary screen and click "Finish."
Now your Windows computer will automatically shutdown at the same time every day/night.

Thursday, November 14, 2013

How to use vlookup in excel

VLOOKUP is one of Excel most useful functions, and it’s also one of the least understood.  In this article, we will discuss about how to use VLOOKUP in excel. So what is VLOOKUP?  Well, of course it’s an Excel function.  This article will assume that the reader already has a passing understanding of Excel functions, and can use basic functions such as SUM, AVERAGE, and TODAY. In its most common usage, VLOOKUP is a database function, meaning that it works with database tables – or more simply, lists of things in an Excel worksheet.  What sort of things?   Well, any sort of thing.  You may have a worksheet that contains a list of employees, or products, or customers, or CDs in your CD collection, or stars in the night sky.  It doesn’t really matter. To use VLOOKUP you can follow this steps below :
  1. Go to Formulas > Insert Function
  2. Type VLOOKUP and click GO and click OK

  3. In window :
    Lookup value choose Field that you want to be looked.
    Table Array choose Reference table from where the value will be looked
    Col Index Num choose field index of table column from where the value will be generated
    Range Lookup True it will use exact match, False for closest match

  4. Press OK

Monday, November 11, 2013

How to install .net framework 3.5 in windows server 2012

If you want to install .NET Framework 3.5 in windows server 2012, you will most likely see this error message when installing the feature:

“Do you want to specify an alternate source path? One or more installation selections are missing source files…”


To solve this, you can follow this steps :
  1. Go to a command prompt and enter this:
    dism /online /enable-feature /featurename:NetFX3 /all /Source:d:\sources\sxs /LimitAccess
    Note: Source should be the Windows installation disc. In my case, this was located on D:
  2. Go down to “Specify an alternate source path” and enter “d:\sources\sxs” as the path.
  3. Now you can install .net framework on your windows 2012 server

Thursday, July 18, 2013

How to join files and compress them into one destination files using zlib in delphi

Do you want to joining some files and compress them into one destination files?. You can do it with your own programming using delphi by copying this code snippet below :

uses Zlib;

procedure CompressFiles(Files : TStrings; const Filename : String);
var
  infile, outfile, tmpFile : TFileStream;
  compr : TCompressionStream;
  i,l : Integer;
  s : String;

begin
  if Files.Count > 0 then
  begin
    outFile := TFileStream.Create(Filename,fmCreate);
    try
      { the number of files }
      l := Files.Count;
      outfile.Write(l,SizeOf(l));
      for i := 0 to Files.Count-1 do
      begin
        infile := TFileStream.Create(Files[i],fmOpenRead);
        try
          { the original filename }
          s := ExtractFilename(Files[i]);
          l := Length(s);
          outfile.Write(l,SizeOf(l));
          outfile.Write(s[1],l);
          { the original filesize }
          l := infile.Size;
          outfile.Write(l,SizeOf(l));
          { compress and store the file temporary}
          tmpFile := TFileStream.Create('tmp',fmCreate);
          compr := TCompressionStream.Create(clMax,tmpfile);
          try
            compr.CopyFrom(infile,l);
          finally
            compr.Free;
            tmpFile.Free;
          end;
          { append the compressed file to the destination file }
          tmpFile := TFileStream.Create('tmp',fmOpenRead);
          try
            outfile.CopyFrom(tmpFile,0);
          finally
            tmpFile.Free;
          end;
        finally
          infile.Free;
        end;
      end;
    finally
      outfile.Free;
    end;
    DeleteFile('tmp');
  end;
end;
 
That's all the script to join files and compress using zlib library in delphi. If there is something error in code implementation, please contact me by leaving your comment below...

Tuesday, July 16, 2013

How to change boot order in vmware workstation bios

Sometimes, in vmware you want to boot from your flashdisk. You can set it by change the first boot sequence in bios. So, how to boot from bios in vmware workstation?..
Below are the step to do it :
  1. Open vmware workstation
  2. Choose your operating system, for example windows server 2003 Enterprise
  3. Choose VM -> Power -> Power on to BIOS in toolbar as below : 

  4. When vmware bios appeared, choose Boot and change boot order as below : 


That is the step to change boot order to removable disk. If you like it, please don't be shy to leave your comment.

Thursday, April 18, 2013

How to mount windows sharing in linux


All files in a Linux system are arranged in one big tree file hierarchy at /. It include devices too. We use the mount command attach the file system or devices to the tree. We also able to mount windows share under Linux as follows :
  1. Make sure you have  : 
    • Windows username and password to access share
    • Sharename or IP address
    • root access on Linux
  2. Login to Linux as a root user
  3. Create mount point:
    # mkdir -p /mnt/winshare
    
  4. Use the mount command as follows :
    # mount -t cifs //ntserver/winshare -o username=admin,password=myAdminPassword /mnt/winshare
    
    while :
    • -t cifs : File system type to be mount
    • //ntserver/winshare : Sharename on windows (change it as yours)
    • -o username=admin,password=myAdminPassword : are options passed to mount command. First argument is username (admin) and second argument is password to connect windows share
    • /mnt/ntserver : Linux mount point to access Sharefiles
  5. Access Windows share using command:
    # cd /mnt/winshare; ls -l
    

Monday, September 24, 2012

How to shutdown windows with command prompt

Sometimes, we don't want to shutdown computer directly, but after next hours because the downloading process that has not been completed. We can do that using command prompt. The following are the steps to do that :
  1. Open the command prompt: Windows Key + R
  2. type the command :
     
    cmd
    
  3. To shutdown local machine with specified time, type this command for example :
     
    shutdown -s -t 60
    

    while 60 is number of seconds before the computer is shutdown.
  4. To shutdown remote machine next 60 second, you can use this command :
     
    shutdown -s -m \\desktop -t 45
    

    while \\desktop is computer ip address or hostname
  5. To cancel shutdown you can use this command :
     
    shutdown -a
    
  6. To get more command you can use help as below :
     
    shutdown --help
    

Thursday, January 12, 2012

How to install web service client application in windows server

This post based on my experience when try to install my web service client application created using delphi. I have no idea, why i was get error when fetching data from web service. The problem is setting of data execution prevention that must be enabled in windows server. The following is the steps to enable data execution prevention :
  1. Click Start, click Control Panel, and then double-click System.
  2. Click the Advanced tab. Then, under Performance, click Settings.
  3. Click the Data Execution Prevention tab.
  4. Click Turn on DEP for essential Windows programs and services only to select the OptIn policy.
  5. Click Turn on DEP for all programs and services except those I select to select the OptOut policy.
  6. If you selected the OptOut policy, click Add and add the applications that you do not want to use DEP with.

Monday, January 9, 2012

How to handle exception in delphi

Almost in all programming language, there are mechanism to handle exception. So do in delphi. We can use try...except mechanism. The following is the example of exception handling in delphi :
var
  bagi, nol : Integer;
begin 
  try
    nol   := 0;
    bagi := 1 div zero;
    ShowMessage('1/0 = ' + IntToStr(bagi));
  except
    on E : Exception do
      ShowMessage(E.ClassName + ' error raised, with message : ' + E.Message);
  end;
end;
In that example, if the try clause generates an exception, it will the execute except clause that will display window showing what type of error generated. This is used to take alternative action when something unexpected goes wrong. Beside that, the other form of handle exception can be done as follow :
var
  bagi, nol : Integer;
begin 
  try
    nol   := 0;
    bagi := 1 div zero;
    ShowMessage('1/0 = ' + IntToStr(bagi));
  finally
    if bagi = -1 then
    begin
      ShowMessage('Number was not assigned a value - using default');
      bagi := 0;
    end;
  end;
end;
In a try...finally construct, the finally statement will be executed absolutely whether thereis error or not. It is normally used to allow cleanup processing, such as freeing memory etc. Both kind of construct cannot be combined together using try..except..finally. So, the question is how to handle exception while we want to execute a set of clean up statements, in other words, how to tricky combine both except and finally ?? This can be done with nested try statements, as construct below :
Try
  Try
    ...
  Except
    ...
  End;
Finally
  ...
End;
Need to be noticed that when you want to test exception handling, don't do it using F9/Run. But do it by execute application (ctrl+f9 then double click application.exe created)

Friday, January 6, 2012

How to insert post programmatically in wordpress

Sometimes, we need to insert post to our blog through code. This case occur in condition for example when we need to insert more than 1 post in 1 time.
Here is the code to do that :
  // Create post object
  $my_post = array();
  $my_post['post_title'] = 'My post';
  $my_post['post_content'] = 'This is my post.';
  $my_post['post_status'] = 'publish';
  $my_post['post_author'] = 1;
  $my_post['post_category'] = array(8,39);
  
  // Insert the post into the database
  wp_insert_post( $my_post );

Tuesday, January 3, 2012

How to get list files of a directory in delphi

Dear reader. Sometimes we need to get list of file names of a directory. This procedure below will do that for us :
procedure GetFilenames(Path: string; Dest: TStrings);
var
  SR: TSearchRec;
begin
  if FindFirst(Path+'*.*', faAnyFile, SR) = 0 then
  repeat
    Dest.Add(SR.Name);
  until FindNext(SR) <> 0;
  FindClose(SR);
end;
 
To use that function, for example you need to create a form with a button and listbox, we name it button1 and listbox1. Here is the code to use that procedure
procedure TForm1.Button1Click(Sender: TObject);
var
  path:string;
begin
  path := 'C:\Movies\';
  GetFilenames(path, ListBox1.Items);
end;
Here is the result when we click on button 'Get List Files Name'
get list files name in delphi

Monday, January 2, 2012

How to substring in delphi

There is almost in every programming language function to substring a string. As well as delphi. To substring a string in delphi use 'copy' function as below :
var s : string;
begin
  s:='Embarcadero';
  s := Copy(s,6,5);
  ShowMessage(s);
 
It will display message 'cader' as below :

Saturday, December 31, 2011

How to create close confirmation in delphi

This post will discuss about how to create a dialog box confirmation when user want to close a form in delphi. Below is the code :
  if MessageDlg('Are you sure you want to close the form?', mtConfirmation,
    [mbOk, mbCancel], 0) = mrCancel then
      CanClose := False;
Paste that code on event OnCloseQuery of form.

Friday, December 30, 2011

How to format strtodatetime in delphi

Because of regional setting computer that depend on each computer, it will output format time as regional setting. If we want to format datetime as we want regardless regional setting, we can write the script as below :
var
  MySettings: TFormatSettings;
  s: string;
  d: TDateTime;
begin
  GetLocaleFormatSettings(GetUserDefaultLCID, MySettings);
  MySettings.DateSeparator := '-';
  MySettings.TimeSeparator := ':';
  MySettings.ShortDateFormat := 'mm-dd-yyyy';
  MySettings.ShortTimeFormat := 'hh:nn:ss';

  s := DateTimeToStr(Now, MySettings);
  ShowMessage(s);
  d := StrToDateTime(s, MySettings);
  ShowMessage(DateTimeToStr(d, MySettings));
end;

Thursday, December 29, 2011

How to convert tstringlist to comma separated string

For some reasons, we may need to convert TListString to a comma separated String. for example to create query that use 'in'. Below is the routine to do that :
var
   oSL : TStringlist;
   sBuffer : String;
begin
   oSL := TStringlist.Create;
   oSL.Add('A');
   oSL.Add('B');
   oSL.Add('C');
   sBuffer := Stringreplace(oSL.Text,Char(13)+Char(10),',',[rfReplaceAll]);
   Showmessage( sBuffer );
   oSL.Free;
end;

Wednesday, December 28, 2011

How to create colored stringgrid in delphi

To make our program look more beautiful, we often add some functionality to handle it's look as well as stringgrid. One way to enhance the appearance is to set it's into the colorful. Below is the script to do that :
var
  dx: Integer;
begin
  with (Sender as TStringGrid) do
  begin
    if (ACol = 0) or (ARow = 0) then
      Canvas.Brush.Color := clBtnFace
    else
    begin
      case ACol of
        1: Canvas.Font.Color := clBlack;
        2: Canvas.Font.Color := clBlue;
      end;
      if ARow mod 2 = 0 then
        Canvas.Brush.Color := $00E1FFF9
      else
        Canvas.Brush.Color := $00FFEBDF;
      Canvas.TextRect(Rect, Rect.Left + 2, Rect.Top + 2, cells[acol, arow]);
      Canvas.FrameRect(Rect);
    end;
  end;
end;
 
Paste that function on event OnDrawCell in stringgrid. The result of your code will look like this :
alternate stringgrid

Tuesday, December 27, 2011

How to locate string in AdoQuery

Sometime for some reasons, we need to locate some values from adoquery result. Below is the function to do that :
if AdoQuery.Locate('NAME', 'jhon', [loPartialKey, loCaseSensitive]) then
Showmessage('Data is found')
else
Showmessage('Data not found');
If you want to locate in more than 1 field you can use ';' as code below :
AdoQuery.Locate('Name;Address',VarArrayOf(['jhon','Arizona']),[]);
The last parameter is optional. You can leave it blank of fill it with 'loPartialKey' or 'loCaseSensitive' as your need.

Monday, December 26, 2011

How to check if TCP Port is Open

When we create an application that open port using winsock, we need to anticipate that user may execute our application twice in order no port conflict error. So we need to check whether that port is already opened at OnCreate event of the form. Below is the function to check that :
uses
  Winsock;

function PortIsOpen(dwPort : Word; ipAddressStr:AnsiString) : boolean;
var
  client : sockaddr_in;
  sock   : Integer;
  ret    : Integer;
  wsdata : WSAData;
begin
 Result:=False;
 ret := WSAStartup($0002, wsdata);
  if ret<>0 then exit;
  try
    client.sin_family      := AF_INET;  
    client.sin_port        := htons(dwPort); 
    client.sin_addr.s_addr := inet_addr(PAnsiChar(ipAddressStr)); 
    sock  :=socket(AF_INET, SOCK_STREAM, 0);    
    Result:=connect(sock,client,SizeOf(client))=0;
  finally
  WSACleanup;
  end;
end;
 
To use that function, write down this code in OnCreate form event
procedure TForm1.FormCreate(Sender: TObject);
begin
if PortIsOpen(1521,'127.0.0.1') then
   showmessage('Port is already opened');
end;
Don't Forget To Join Our Community
×
Widget