Showing posts with label IT. Show all posts
Showing posts with label IT. Show all posts

Friday, September 4, 2020

Ant compile JavaFX project which depends on another one

Oracle Doc said that JavaFX Ant tasks and the JavaFX Packager tool are currently the only supported ways to package JavaFX applications.


I have a JavaFX project client which depends on another common project tool. Under project client, the ant build.xml as below:


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

 

<project name="Atlas Tool Server" default="default" basedir="."

  xmlns:fx="javafx:com.sun.javafx.tools.ant">

 

  <property name="JAVA_HOME" value="C:\\Program Files\\Java\\jdk1.8.0_261"/>

  <property name="build.src.dir" value="src"/>

  <property name="build.classes.dir" value="classes"/>

  <property name="build.dist.dir" value="dist"/>

  <property name="COMMON_HOME" value="../AtlasTool"/>

  <property name="build.common.src.dir" value="${COMMON_HOME}\\src"/>

 

  <target name="default" depends="clean,compile,copyfile">

 

    <taskdef resource="com/sun/javafx/tools/ant/antlib.xml"

      uri="javafx:com.sun.javafx.tools.ant"

      classpath="${JAVA_HOME}/lib/ant-javafx.jar"/>

 

      <fx:application id="AtlasToolServerID"

        name="AtlasToolServerApp"

        mainClass="com.atlasserver.Launcher"/>

 

      <fx:resources id="appRes">

        <fx:fileset dir="${build.dist.dir}" includes="AtlasToolServer.jar"/>

      <fx:fileset dir="${build.dist.dir}" includes="DatabaseConfig.properties"/>

  <fx:fileset dir="${build.dist.dir}">

  <include name="lib/**" />

  </fx:fileset>

      </fx:resources>

 

      <fx:jar destfile="${build.dist.dir}/AtlasToolServer.jar">

        <fx:application refid="AtlasToolServerID"/>

        <fx:resources refid="appRes"/>

        <fileset dir="${build.classes.dir}"/>

      </fx:jar>

 

      <fx:deploy width="300" height="250"

        outdir="." embedJNLP="true"

        outfile="atlastoolclient" nativeBundles="all">

 

        <fx:application refId="AtlasToolServerID"/>

 

        <fx:resources refid="appRes"/>

 

        <fx:info title="Atlas Tool Server"

          vendor="bq"/>

 

      </fx:deploy>

 

  </target>

 

  <target name="clean">

    <mkdir dir="${build.classes.dir}"/>

    <mkdir dir="${build.dist.dir}"/>

 

  <!--mkdir dir="${build.classes.dir}/com/atlastool/view"/>

  <mkdir dir="${build.classes.dir}/com/atlasserver/view"/-->


    <delete>

      <fileset dir="${build.classes.dir}" includes="**/*"/>

      <fileset dir="${build.dist.dir}" includes="**/*"/>

    </delete>

 

  </target>

 

  <target name="compile" depends="clean">

  <path id="classpath">

          <fileset dir="${COMMON_HOME}/lib">

              <include name="*.jar"/>

          </fileset>

  </path>

    <javac includeantruntime="false"

      srcdir="${build.src.dir}:${build.common.src.dir}"

      destdir="${build.classes.dir}"

      fork="yes"

      executable="${JAVA_HOME}/bin/javac"

      source="1.8"

      debug="on"

      encoding="UTF-8">

    <classpath refid="classpath"/>

    </javac>

  </target>

 

  <target name="copyfile" depends="compile">

  <copy todir="${build.classes.dir}">

      <fileset dir="${COMMON_HOME}/resources"/>

  </copy>

 

  <copy todir="${build.dist.dir}/lib">

  <fileset dir="${COMMON_HOME}/lib">

  </fileset>

  </copy>

 

  <copy todir="${build.dist.dir}" file="${COMMON_HOME}/DatabaseConfig.properties"/>

 

  <copy todir="${build.dist.dir}">

  <fileset dir="${COMMON_HOME}">

          <include name="${COMMON_HOME}/DatabaseConfig.properties"/>

  </fileset>

  </copy>

  <copy todir="${build.classes.dir}/com/atlastool/view">

      <fileset dir="${build.common.src.dir}/com/atlastool/view"/>

  </copy>

  <copy todir="${build.classes.dir}/com/atlasserver/view">

      <fileset dir="${build.src.dir}/com/atlasserver/view"/>

  </copy>

</target>

</project>

Monday, January 6, 2020

Full-text search example

if object_id(N'[dbo].[FTSearch]',N'U') is not null
   drop table [dbo].[FTSearch]
go

CREATE TABLE [dbo].[FTSearch]
(PK INT NOT NULL IDENTITY(1,1) CONSTRAINT fs_primarykey PRIMARY KEY, def varchar(max), [type] varchar(max), name varchar(max))
go

insert into [dbo].[FTSearch] ([type], name, def)
      SELECT
      obj.type_desc, -- [Object Type],
      obj.name,      -- [Object Name],      
      com.definition  -- [Text]
   FROM sys.sql_modules com
   JOIN sys.objects obj ON obj.object_id = com.object_id and SCHEMA_NAME(schema_id) <> 'sys' AND is_ms_shipped = 0
   ORDER BY obj.name
go

IF EXISTS ( SELECT 1 FROM sys.fulltext_indexes fti WHERE fti.object_id = OBJECT_ID(N'[dbo].[FTSearch]') ) 
   DROP FULLTEXT INDEX ON #FTSearch
go

IF EXISTS ( SELECT 1 FROM sysfulltextcatalogs ftc WHERE ftc.name = N'TestFTSearch' ) 
   DROP FULLTEXT CATALOG [TestFTSearch]
go

CREATE FULLTEXT CATALOG [TestFTSearch] WITH ACCENT_SENSITIVITY = ON AS DEFAULT AUTHORIZATION [dbo]
go

CREATE FULLTEXT INDEX ON [dbo].[FTSearch]([def]) KEY INDEX fs_primarykey ON ([TestFTSearch]) WITH (CHANGE_TRACKING AUTO)
go

ALTER FULLTEXT INDEX ON [dbo].[FTSearch] ENABLE
go

WHILE FulltextCatalogProperty('TestFTSearch','PopulateStatus') <> 0   
BEGIN  
   WAITFOR DELAY '00:00:05' 
END 

SELECT *
FROM [dbo].[FTSearch]
WHERE CONTAINS([def], 'CheckPOBuilderViewsSp')

Adjust dropdown width according to longest content (VB)

        For Each item As String In cboToResource.Items
            If TextRenderer.MeasureText(item, cboToResource.Font).Width > (cboToResource.DropDownWidth - SystemInformation.VerticalScrollBarWidth) Then
                cboToResource.DropDownWidth = TextRenderer.MeasureText(item, cboToResource.Font).Width + SystemInformation.VerticalScrollBarWidth
            End If
        Next

        cboToResource.ClientSize = New Size(cboToResource.DropDownWidth, cboToResource.ClientSize.Height)

Thursday, July 25, 2019

Parse XML with namespace based on xslt

    There is a xml file (sample.xml) which contains a self-defined namespace. I want to retrieve <w:r><w:t> value and that <w:r> should not contain child <w:pict> inside it. So, as per my below XML Document i want to generate following output:
<paragraph>This is the text that i need to retrieve...</paragraph>
    
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<?xml-stylesheet type="text/xsl" href="sample.xsl"?>
<w:document xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
<w:body>
    <w:p> <!-- Current Node -->
        <w:r>
            <w:t>
                 This is the
            </w:t>
        </w:r>
        <w:r>
            <w:pict>
                <w:p>
                    <w:r>
                        <w:t>
                            I dont need this
                        </w:t>
                    </w:r>
                </w:p>
            </w:pict>
        </w:r>
        <w:r>
            <w:pict>
                <w:p>
                    <w:r>
                        <w:t>
                            I dont need this too
                        </w:t>
                    </w:r>
                </w:p>
            </w:pict>
        </w:r>
        <w:r>
            <w:t>
                 text that i need to retrieve...
            </w:t>
        </w:r>
    </w:p>
</w:body>
</w:document>
        
 The relative xslt file (sample.xsl) as below:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
<xsl:template match="/">
  <html>
    <body>
      <table border="1"><td>
        <![CDATA[<paragraph>]]>
          <xsl:for-each select="//w:r[not(ancestor::w:pict)]">
            <xsl:value-of select="w:t"/>
          </xsl:for-each>
        <![CDATA[</paragraph>]]></td>
      </table>
    </body>
  </html>
</xsl:template>

</xsl:stylesheet>

Check and release the used port

1 Click Start->Run->cmd or press key Win+R to call the command line window.

2 Input command netstat -aon|findstr "8080" and press Enter key to check the PID of the process that using the port. e.g. 2623

3 Input command tasklist|findstr "2623" and press Enter key to check the relative process name. e.g. javaw.exe

4 Input command taskkill /f /t /im javaw.exe and press Enter key to kill the relative process.

Fetch data from another DB server (sql server)

way 1:
exec   sp_addlinkedserver     'srv_lnk','','SQLOLEDB','cnshdnfeng1'   
exec   sp_addlinkedsrvlogin   'srv_lnk','false',null,'sa','sa'  
go

select * from   srv_lnk.SunSystemsData.dbo.ANL_DIR
exec   sp_dropserver   'srv_lnk','droplogins'

way 2:
sp_configure 'show advanced options', 1;
GO
RECONFIGURE;
GO
sp_configure 'Ad Hoc Distributed Queries', 1;
GO
RECONFIGURE;
GO
select * from openrowset('SQLOLEDB','cnshdnfeng1';'sa';'sa', SunSystemsData.dbo.ANL_DIR)

Summary for synchronization in .NET

The following tables summarize the .NET tools available for coordinating or synchronizing the actions of threads:

1 Simple Blocking Methods
    
ConstructPurpose
SleepBlocks for a given time period
JoinWaits for another thread to finish

2 Locking Constructs
ConstructPurposeCross Process?Speed
LockEnsures just one thread can access a resource, or section of code.NoFast
MutexEnsures just one thread can access a resource, or section of code. Can be used to prevent multiple instances of an application from starting.YesModerate
SemaphoreEnsures not more than a pecified number of therads can access a resource, or section of code.YesModerate

(Synchronization Context are also provided, for automatic locking)
3 Signaling Constructs
ConstructPurposeCross Process?Speed
EventWaitHandleAllows a thread to wait until it receives a signal from another therad.YesModerate
Wait & PulseAllows a thread to wait until a custom blocking condition is met.NoModerate
4 Non-Blocking Synchronization Constructs
ConstructPurposeCross Process?Speed
InterlockedTo perform simple non-blocking atomic operations.Yes (Assuming shared memory)Very fast
volatileTo allow safe non-blocking access to individual fields outside of a lock.Yes (Assuming shared memory)Very fast

Identify process mode and check .NET process

1 Identify the mode of process:

1.1 Identify the mode of one process:
dumpbin /headers cv210.dll

1.2 Identify the modes of all processes on the current computer:

using System;
using System.Diagnostics;
using System.Runtime.InteropServices;

namespace WinProcessModeChecker {
    internal class Program {
        private static void Main() {
            if (Is64OsVersion()) {
                PrintProcessMode();
            } else {
                Console.WriteLine("Your OS version is not 64 bit!");
            }
                
            Console.ReadLine();
        }

        private static void PrintProcessMode() {
            foreach (var process in Process.GetProcesses()) {
                var isWow64Process = IsWow64Process(process);

                if (isWow64Process == null) {
                    Console.WriteLine(process.ProcessName + " is denied to access");
                } else if (isWow64Process == true) {
                    Console.WriteLine(process.ProcessName + " is 32-bit (wow mode)");
                } else {
                    Console.WriteLine(process.ProcessName + " is 64-bit");
                }
            }
        }

        /// <summary>
        /// Identify whether the OS version is 64 bit
        /// </summary>
        /// <returns></returns>
        private static bool Is64OsVersion() {
            if ((Environment.OSVersion.Version.Major > 5)
                || ((Environment.OSVersion.Version.Major == 5) && (Environment.OSVersion.Version.Minor >= 1))) {
                return true;
            }

            return false;
        }

        /// <summary>
        /// Identify whether the process is running in wow 64 mode 
        /// </summary>
        /// <remarks>
        /// WOW64 is the x86 emulator that allows 32-bit Windows-based applications to run seamlessly on 64-bit Windows
        /// </remarks>
        /// <param name="process"></param>
        /// <returns></returns>
        private static bool? IsWow64Process(Process process) {
            IntPtr processHandle;
            bool retVal;

            try {
                processHandle = Process.GetProcessById(process.Id).Handle;
            } catch {
                return null; // access is denied to the process
            }

            return NativeMethods.IsWow64Process(processHandle, out retVal) && retVal;
        }
    }

    internal static class NativeMethods {
        [DllImport("kernel32.dll", SetLastError = true, CallingConvention = CallingConvention.Winapi)]
        [return : MarshalAs(UnmanagedType.Bool)]
        internal static extern bool IsWow64Process([In] IntPtr process, [Out] out bool wow64Process);
    }
}

2 Chech .Net process:

2.1 The .NET application requires mscoree.dll So can use the below code:

  foreach (var process in Process.GetProcesses())
        {
            if (process.Modules.OfType<ProcessModule>().Any(m => m.ModuleName == "mscoree.dll"))
            {
                Console.WriteLine("{0} is a .NET process", process.ProcessName);
            }
        }
2.2 Process Explorer mark .NET applications by yellow color by default. 

Common schema clause

-- Add UDDT: AU_EdiDateOffsetHoursType
IF NOT EXISTS (SELECT 1 FROM sys.types st JOIN sys.schemas ss ON st.schema_id = ss.schema_id 
   WHERE st.name = N'AU_EdiDateOffsetHoursType' AND ss.name = N'dbo')
   CREATE TYPE [dbo].[AU_EdiDateOffsetHoursType] FROM smallint NULL
GO

--Create Table: AU_co_contract_line_mst
IF OBJECT_ID(N'[dbo].[AU_co_contract_line_mst]', N'U') IS NULL
CREATE TABLE [dbo].[AU_co_contract_line_mst](
      [site_ref] [dbo].[SiteType] NOT NULL
         CONSTRAINT [DF_AU_co_contract_line_mst_site_ref] DEFAULT (RTRIM(CONVERT([nvarchar](8),context_info(),0)))
    , [contract_id] [dbo].[AU_ContractIDType] NOT NULL
    , [co_num] [dbo].[CoNumType] NOT NULL 
    , [cust_item] [dbo].[CustItemType] NULL
    , [CreatedBy] [dbo].[UsernameType] NOT NULL
        CONSTRAINT [DF_AU_co_contract_line_mst_CreatedBy]  DEFAULT (SUSER_SNAME())
    , [UpdatedBy] [dbo].[UsernameType] NOT NULL 
        CONSTRAINT [DF_AU_co_contract_line_mst_UpdatedBy]  DEFAULT (SUSER_SNAME())
    , [CreateDate] [dbo].[CurrentDateType] NOT NULL 
        CONSTRAINT [DF_AU_co_contract_line_mst_CreateDate]  DEFAULT (GETDATE())
    , [RecordDate] [dbo].[CurrentDateType] NOT NULL 
        CONSTRAINT [DF_AU_co_contract_line_mst_RecordDate]  DEFAULT (GETDATE())
    , [RowPointer] [dbo].[RowPointerType] NOT NULL 
        CONSTRAINT [DF_AU_co_contract_line_mst_RowPointer]  DEFAULT (NEWID())
    , [NoteExistsFlag] [dbo].[FlagNyType] NOT NULL 
        CONSTRAINT [DF_AU_co_contract_line_mst_NoteExistsFlag]  DEFAULT ((0)) 
        CONSTRAINT [CK_AU_co_contract_line_mst_NoteExistsFlag] CHECK ([NoteExistsFlag] IN (0,1))
    , [InWorkflow] [dbo].[FlagNyType] NOT NULL 
        CONSTRAINT [DF_AU_co_contract_line_mst_InWorkflow]  DEFAULT ((0))
        CONSTRAINT [CK_AU_co_contract_line_mst_InWorkflow] CHECK ([InWorkflow] IN (0,1))
    , CONSTRAINT [PK_AU_co_contract_line_mst] PRIMARY KEY CLUSTERED 
       (
           [contract_id] ASC,
           [co_num] ASC,
           [co_line] ASC,
           [site_ref]
       )
    , CONSTRAINT [IX_AU_co_contract_line_mst_RowPointer] UNIQUE NONCLUSTERED 
      ( 
         [RowPointer]
        ,[site_ref]
      )
   )   
GO

-- Add column with constraints
IF OBJECTPROPERTY(OBJECT_ID(N'[dbo].[so_parms]'), N'IsUserTable') = 1
   AND NOT EXISTS (SELECT 1 FROM [sys].[columns]
      WHERE [object_id] = OBJECT_ID(N'[dbo].[so_parms]')
      AND [name] = N'stat_code')
   ALTER TABLE [dbo].[so_parms] ADD
      [stat_code] [dbo].[FSStatCodeType] NOT NULL
         CONSTRAINT [DF_so_parms_stat_code]  DEFAULT (1)
         CONSTRAINT [CK_so_parms_stat_code] CHECK ([pick_list_printed] IN (0, 1))
         CONSTRAINT [FK_so_parms_stat_code] FOREIGN KEY ([stat_code]) 
            REFERENCES [dbo].[fs_stat_code]([stat_code]) NOT FOR REPLICATION
GO

IF COL_LENGTH('dbo.CRMMobileDeviceIdo', 'IsReadOnly')  IS NULL
   ALTER TABLE [dbo].[CRMMobileDeviceIdo] ADD [IsReadOnly] [dbo].[ListYesNoType] NOT NULL DEFAULT 0;
GO

-- Add FK between AU_co_contract_line_prc_mst and AU_co_contract_line_mst
IF OBJECTPROPERTY(OBJECT_ID(N'[dbo].[AU_co_contract_line_prc_mst]'), N'IsUserTable') = 1
   AND NOT EXISTS (SELECT 1 FROM [sys].[objects]
   WHERE [OBJECT_ID] = OBJECT_ID(N'FK_AU_co_contract_line_prc_mst_contract_id_co_num_co_line_site_ref'))
   ALTER TABLE [dbo].[AU_co_contract_line_prc_mst] WITH NOCHECK 
   ADD CONSTRAINT [FK_AU_co_contract_line_prc_mst_contract_id_co_num_co_line_site_ref]
   FOREIGN KEY (
           [contract_id],
           [co_num],
           [co_line],
           [site_ref]
   ) REFERENCES [dbo].[AU_co_contract_line_mst](
           [contract_id],
           [co_num],
           [co_line],
           [site_ref]
   ) NOT FOR REPLICATION
GO

-- Add Check Constraint
IF  EXISTS (SELECT 1 FROM sys.check_constraints WHERE object_id = OBJECT_ID(N'[dbo].[CK_arpmtd_type]') AND parent_object_id = OBJECT_ID(N'[dbo].[arpmtd]'))
ALTER TABLE [dbo].[arpmtd] DROP CONSTRAINT [CK_arpmtd_type]
GO
ALTER TABLE [dbo].[arpmtd] WITH CHECK ADD  CONSTRAINT [CK_arpmtd_type] CHECK  (([type]='S' OR ([type]='D' OR ([type]='A' OR ([type]='W' OR [type]='C')))))
GO
ALTER TABLE [dbo].[arpmtd] CHECK CONSTRAINT [CK_arpmtd_type]
GO

-- Remove existed FK
IF EXISTS (SELECT 1 
           FROM sys.foreign_keys 
           WHERE OBJECT_ID = OBJECT_ID(N'fs_parmsFk57')
           AND   parent_OBJECT_ID = OBJECT_ID(N'[dbo].[fs_parms]')
)
BEGIN
   ALTER TABLE [dbo].[fs_parms] DROP CONSTRAINT [fs_parmsFk57]
END
GO

-- Remove Existed column
IF EXISTS (SELECT 1 FROM  sys.columns c 
           INNER JOIN  sys.objects t ON (c.[OBJECT_ID] = t.[OBJECT_ID])
           WHERE t.[OBJECT_ID] = OBJECT_ID(N'[dbo].[fs_parms]')
           AND   c.[name] = N'parts_sro_template')
BEGIN 
   ALTER TABLE [dbo].[fs_parms] DROP COLUMN parts_sro_template
END
GO

-- Create Stored Procedure
SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

IF EXISTS (SELECT 1 FROM sysobjects WHERE id = object_id(N'MilestoneOperationCheckSp') 
AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   DROP PROCEDURE MilestoneOperationCheckSp
GO

CREATE PROCEDURE MilestoneOperationCheckSp (  
   @PSroNum            FSSRONumType
 , @Infobar            Infobar      = NULL OUTPUT
) AS  
  
DECLARE 
   @Severity INT  

SET @Severity = 0

RETURN @Severity 

-- Create Function
SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

IF EXISTS (SELECT 1 FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[SarbCalSp]') AND OBJECTPROPERTY(id, N'IsScalarFunction') = 1)
   DROP FUNCTION [dbo].[SarbCalSp]
GO

CREATE FUNCTION dbo.SarbCalSp (
  @PFutureDate DateType
, @PNewDate    DateType
)
RETURNS SMALLINT
AS
BEGIN
   RETURN (month(@PNewDate) - month(@PFutureDate)) + (year(@PNewDate) - year(@PFutureDate)) * 12
END

-- Create Trigger
SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[UserNamesAppDel]') AND OBJECTPROPERTY(id, N'IsTrigger') = 1)
DROP TRIGGER [dbo].[UserNamesAppDel]
GO

CREATE TRIGGER dbo.UserNamesAppDel
ON UserNames
FOR DELETE
AS
-- Skip trigger operations as required.
IF dbo.SkipBaseTrigger() = 1
   RETURN
DECLARE sssFSUsernamesDelCrs CURSOR LOCAL STATIC
FOR SELECT 
  dd.RowPointer
, dd.username
FROM deleted AS dd

OPEN sssFSUsernamesDelCrs

WHILE @Severity = 0
BEGIN -- cursor loop
   FETCH sssFSUsernamesDelCrs INTO
     @RowPointer
   , @Username

   IF @@FETCH_STATUS = -1
      BREAK
END -- End of cursor loop

CLOSE sssFSUsernamesDelCrs
DEALLOCATE sssFSUsernamesDelCrs

IF @Severity = 0
BEGIN
  DELETE user_local
  FROM
    deleted dd
   ,user_local ul
  WHERE ul.UserId = dd.UserId

  SELECT @Severity = @@ERROR
END
/* return error result */
IF @Severity <> 0
BEGIN
    EXEC RaiseErrorSp @Infobar, @Severity, 3
 
    EXEC @Severity = RollbackTransactionSp
       @Severity
 
    IF @Severity != 0
    BEGIN
       ROLLBACK TRANSACTION
       RETURN
    END
END

Common Used Batch Commands

Create file folder:
md "E:\My documents\Newfolder1"

Search specific file:
dir d:\ e:\ /s /b | find "x.x"

Create an empty file:
cd. > a.txt
cd. Indicates that the current directory is changed to the current directory, that is, it is not changed; And this command has no output
> Indicates that the command output is written to a file. Followed by a.txt, it means to write to a.txt.
In this case, the command will not have output, so an empty file with no content is created.

copy nul a.txt
Nul represents an empty device. Conceptually, it is invisible and exists in each directory. It can be regarded as a special "file" with no content; Generally, the output can be written to nul to mask the output. For example, pause > nul, the execution effect of this command is to pause, and "please press any key to continue..." will not be displayed.
This example shows that an empty device is copied to a.txt, and an empty file without content is also created.

type nul > 1.txt
This example shows that the contents of an empty device are displayed and written to a.txt

fsutil file createnew a2.txt 1
An empty file was created using fsutil.

echo a 2 > a.txt
"2" indicates the handle of error output. In this case, there is no error output, so an empty file without content is created.
In fact, the default is to redirect handle 1, that is, the standard output handle. For example, CD. > a.txt is actually CD. 1 > a.txt.
Similarly, handles 3 to 9 can also be used. In this case, they are undefined handles and will not have output, such as echo a 3>a.txt

Create a non-empty file
echo a > a.txt
The most commonly used command is echo. This example means that the letter A and carriage return line feed are overwritten and output to a.txt (if the original content of a.txt is overwritten), if you add content, you can use >>. For example, echo b >> a.txt means that B and carriage return line feed are appended to the end of the file.

View file:
type "ApplicationDB\Stored Procedures\Rpt_CfgAttrSp.sp" 

Append data to existed file:
COPY filename+CON
TYPE CON>>filename
After input press key F6 or Ctrl+Z

Delete file:
rd /s /q %windir%\temp & md %windir%\temp
del /f /s /q %systemdrive%\*.tmp

Delete file whose name contains space:
for /r "C:\Test" %v in (*.txt) do del "%v"

Copy files:
copy d:\test.txt+d:\abc.txt d:\test\test.txt
type a.txt > b.txt
copy a.txt b.txt
fsutil file createnew d:\a.txt 1

Copy from another computer:
xcopy \\cnshdbqin1\resource D:\res /s /c

Copy from another computer with user and password:
net use \\10.86.26.167\fs1 P@ssword123 /user:shareuser
xcopy \\10.86.26.167\fs1\grampian.csv D:\res /s /c
net use \\10.86.26.167\fs1 /delete

Multi-threaded file copy:
robocopy d:\work e:\back /s /j /xf *.tmp *.bak

Open the program:
start d:\TheWorld\TheWorld.EXE "e:\My documents\I_have_a_page.htm"

Open website:
@echo off
path=%path%; C:\Program Files\Internet Explorer\iexplore.exe
start iexplore http://cnshvwmg902ap01/WSWebClient/WSWebForm.aspx

Open folder:
@echo off
start "" "\\cnshwfps2\Departments\R&D"

Receive the value from command line:
set /p a=
echo Your input is: %a%

Check local port:
netstat -aon | find "80"
tasklist | findstr "3096"

Search local string:
findstr /S /N "Option" C:\vss_root\ \(-name \*.txt -o -name \*.vb -o -name \*.sql \)

Change password of :
Remote Computer: Ctrl+Alt+End
Local Computer:  Ctrl+Alt+Del

Remote desktop connect command:
mstsc /v: USCOVWCS10DB /console

Minmun all windows except current:
win+Home

Shift window between different screens:
Press key WIN+SHIFT+LEFT | RIGHT

Run a program as an administrator
Press key CTRL+SHIFT and Click the exe file

Close the process of remote computer:
tasklist /S cnshdbqin2 /U infor\bqin /P Winter_01
 |FIND /i "taskmgr" && (echo OK || echo error) && taskkill /S cnshdbqin2 /U info
r\bqin /P Winter_01 /im taskmgr.exe

Wait for some time:
ping 1.1.1.1 -n 1 -w 30000
timeout /t 10

Show the control set:
rundll32.exe shell32.dll,Control_RunDLL

Fix IE:
regsvr32 Shdocvw.dll
regsvr32 Oleaut32.dll 
regsvr32 Actxprxy.dll 
regsvr32 Mshtml.dll 
regsvr32 Urlmon.dll 
regsvr32 browseui.dll