Posts

Showing posts from 2015

Can't delete OU in Active Directory Users and Computers

Problem. You don’t have sufficient privileges to delete [OU], or this object is protected from accidental deletion. Solution. Go to menu >> View >> Advanced Features. Right Click on OU and choose properties. Choose security tab. Unchecked Protect object from accidental deletion

Client Information and Convert to MD5

Imports System Imports System.Management Imports System.Security.Cryptography Imports System.Text Public Class Form1     Private Function CpuId() As String         Dim computer As String = "."         Dim wmi As Object = GetObject("WinMgmts:")         Dim processors As Object = wmi.InstancesOf("Win32_Processor")         Dim cpu_ids As String = ""         For Each cpu As Object In processors             cpu_ids = cpu_ids & ", " & cpu.ProcessorId         Next cpu         If cpu_ids.Length > 0 Then cpu_ids = cpu_ids.Substring(2)         Return cpu_ids     End Function     Private Function SystemSerialNumber() As String         ' Get the Windows Management Instrumentation object.         Dim wmi As Object = GetObject("WinMgmts:")         ' Get the "base boards" (mother boards).         Dim serial_numbers As String = ""         Dim mother_boards As Object = wmi.Insta
Problem ::   java.lang.RuntimeException: java.lang.IllegalArgumentException: Argument for @NotNull parameter 'name' of com/android/tools/idea/welcome/Platform. must not be null Solution ::  Open the folder "bin" under the directory where you installed your Android Studio. Find the file "idea.properties" and open it with Notepad++/UltraEdit/other_edit_tools. Add "disable.android.first.run=true" as the final line and save the file. Restart Android Studio.

วิธีตั้งค่า NTP บน Primary Domain Controller

     วิธีการตั้งค่าให้ระบบ Domain Controller ทำการ Sync Time จากภายนอกและทำตัวเองให้เป็น NTP Server ด้วย (Hyper-v ให้ทำการติ๊ก Time Sync ออกด้วยนะครับ) แบบ Command  # w32tm /config /manualpeerlist: " time.navy.mi.th, clock.nectec.or.th"  /syncfromflags:manual /reliable:yes  # w32tm /config /update  # net stop w32time && net start w32time # w32tm /resync      คราวนี้ Client ภายในบริษัทก็สามารถ Sync Time ที่ Server ได้แล้วไม่ต้องไป Sync Time ที่ข้างนอกให้เปลือง Bandwidth Internet แล้วจ้า

MD5 Encryption

Imports System.Text Imports System.IO Shared Function GetMd5Hash(ByVal md5Hash As MD5, ByVal input As String) As String         ' Convert the input string to a byte array and compute the hash.         Dim data As Byte() = md5Hash.ComputeHash(Encoding.UTF8.GetBytes(input))         ' Create a new Stringbuilder to collect the bytes         ' and create a string.         Dim sBuilder As New StringBuilder()         ' Loop through each byte of the hashed data          ' and format each one as a hexadecimal string.         Dim i As Integer         For i = 0 To data.Length - 1             sBuilder.Append(data(i).ToString("x2"))         Next i         ' Return the hexadecimal string.         Return sBuilder.ToString() End Function 'GetMd5Hash Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load         Dim md5Hash As MD5 = MD5.Create()         Dim x As String         Dim var_password

Sub Handle Multiple Event

กรณีที่เราสร้างปุ่มไว้หลายๆอัน แล้วแต่ละปุ่มมี Event ที่เหมือนๆกัน เราสามารถเขียนอยู่ใน Sub เดียวกันได้ Private Sub AllButton_Click(sender As Object, e As EventArgs) Handles Button1.Click, Button2.Click     Dim x As Button 'สร้างตัวแปรที่เป็น Button     x = CType(sender, Button) 'รับค่า Sender มาแล้วทำการแปลงให้เป็น Button     Label1.Text = x.Text 'แสดงข้อความบนปุ่มที่ label1 End Sub

BackgroundWorker Control

ตัวอย่างนี้ เป็นคอนโทรลที่ใช้ในการทำงานแบบอยู่เบื้องหลัง ไม่กระทบกับการทำงานเบื้องหน้า หรือที่เรียกกันว่า Asynchronous นั่นเองครับ     Private Sub BackgroundWorker1_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork         For i As Integer = 0 To 100 Step +1             If BackgroundWorker1.CancellationPending = True Then                 e.Cancel = True                 Exit For             Else                 BackgroundWorker1.ReportProgress(i)                 System.Threading.Thread.Sleep(100)             End If         Next     End Sub     Private Sub BackgroundWorker1_ProgressChanged(sender As Object, e As System.ComponentModel.ProgressChangedEventArgs) Handles BackgroundWorker1.ProgressChanged         ProcessBar.Value = e.ProgressPercentage         lbl_percent.Text = e.ProgressPercentage & "%"     End Sub     Private Sub BackgroundWorker1_RunWorkerCompleted(sender As Object, e As System.Component

AutoComplete Extension

Image
1. Add Connection String to web.config <connectionStrings>     <add name="conn" connectionString="Data Source=SERVER;Initial Catalog=DB; User ID=USER;Password=PASSWORD" providerName="System.Data.SqlClient"/> </connectionStrings> 2. Insert Control ScriptManager, Textbox and add AutoComplete Extension <%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %> <%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server">     <title></title> </head> <body>     <form id="form1" runat="server">     <div>              <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageM

Problem :: Windows cannot log you on because your profile cannot be loaded.

    ปัญหาเมื่อทำการ Login เข้า Windows แล้วพบข้อความขึ้นว่า Windows cannot log you on because your profile cannot be loaded. อันดับแรกให้ทำการตรวจสอบ Network ก่อนว่าสามารถใช้งานได้ตามปกติไหม ถ้าใช้งานได้ตามปกติแล้วแต่ยังไม่สามารถ login ได้ ตามนี้เลยครับ 1. Login to Local Administrator or Domain Administrator 2. Go to Start > Run > Regedit 3. HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\ProfileList\S-1-5-21[xxxx] 4. ให้ทำการเลือกหา User Profile ของ User ที่มีปัญหา โดยดูที่ ProfileImagePath หลังจากที่พบแล้ว 5. ให้ทำการแก้ไข RefCount ให้เป็น 0 และ State ให้เป็น 0  6. ทำการ Restart Computer แล้วทำการ Login เข้าใช้งานได้ตามปกติ

AJAX ModalPopup Extension + JavaScript

Image
Instruction Step. 1. Insert CSS for ModalPopup extension. 2. Insert ScriptManager. 3. Insert GridView. 4. Insert Panel1 and Control. 5. Config LinkButton by Add modalpopup extension and set PopupControlID = Panel1. 6. Code-Behind :: Load data to gridview on Page_Load event. 7. Code-Behind :: Insert javascript to linkbutton. 8. Code-Behind :: Update data by update button. modalpopup.aspx <%@ Page Language="VB" AutoEventWireup="false" CodeFile="T1.aspx.vb" Inherits="T1" Trace="false" %> <%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server">     <title></title>     <style type="text/css">         .modalPopup          {             background-color:yellow;             border-width:1px;  

Rename Extension (All files include sub folders)

I change .txt file to .ext file on c:\test\ include sub folder. Get-ChildItem - path C:\TEST -recurse -include *.txt | Rename-Item -NewName {$_.name -replace '\.txt','.ext'}

Full Screen Mode

Properties of Form FormBorderStyle set to none WindowState set to maximize