大掃除~用批次檔清理電腦

過年大掃除,你有幫你的電腦大掃除了嗎~

我前陣子幫家裡兩台NB重新安裝一次Windows,還做了系統備份,希望新年的開始能跑的穩定點~但還有4台電腦等著我維護...工作這麼忙,重安裝又要重設定~哪那麼多閒功夫呀~

那麼至少清除一下電腦中暫存的垃圾吧~懂電腦的人就會知道電腦中的垃圾要去哪清~

不過一個一個手動清除會不會太慢了點~這時弄個批次檔就解決啦~

作法

打開記事本,填入以下命令,然後存檔時命名為【cleanSystem.bat】

@echo off
echo 正在清除系統垃圾檔案中,請稍候......
del /f /s /q %systemdrive%\*.tmp
del /f /s /q %systemdrive%\*._mp
del /f /s /q %windir%\*.log
del /f /s /q %systemdrive%\*.gid
del /f /s /q %systemdrive%\*.chk
del /f /s /q %systemdrive%\*.old
del /f /s /q %systemdrive%\*.bak
del /f /s /q %systemdrive%\recycled\*.*
del /f /s /q %windir%\*.bak
del /f /s /q %windir%\prefetch\*.*
rd /s /q %windir%\temp & md %windir%\temp
del /f /q %userprofile%\cookies\*.*
del /f /q %userprofile%\recent\*.*
del /f /s /q "%userprofile%\Local Settings\Temporary Internet Files\*.*"
del /f /s /q "%windir\Temporary Internet Files\*.*"
del /f /s /q "%userprofile%\Local Settings\Temp\*.*"
del /f /s /q "%userprofile%\recent\*.*"
del /f /s /q "%temp%\*.*"
echo 清除系統垃圾檔案完成!!
echo. & pause

再來點兩下這個檔讓它執行就好啦~

原理

簡單來說,這個批次檔執行後,會將你系統根目錄(如C:\)下的一些暫存檔、備份檔改刪除~

然後刪除系統目錄(如C:\WINDOWS)下的備份檔~

再來就是暫存區的檔案與瀏覽器的暫存區~

完成後基本上大多數的垃圾就消失了~

覺得不夠乾淨?

那麼建議你做一些標準清除的動作

  • 開始→程式集→附屬應用程式→系統工具→清理磁碟 (對應指令: cleanmgr)
  • 清除瀏覽器暫存檔案與 Cookie (Internet Explorer 5.5/6.0 適用):
    • 結束 Internet Explorer,然後結束「Windows 檔案總管」的所有執行個體。
    • 按一下 [開始],再按一下 [控制台],然後按兩下 [網際網路選項]。
    • 按一下 [一般] 索引標籤,然後按一下 [Temporary Internet files] 下方的 [刪除檔案]。
    • 在 [刪除檔案] 對話方塊中,按一下以選取 [刪除所有離線內容] 核取方塊,然後按一下 [確定]。
    • 按一下 [確定]。
  • 清除瀏覽器暫存檔案與 Cookie (Mozilla Firefox 適用):
    • 啟動 Mozilla Firefox
    • 點選「Tools」→「Options」
    • 點選「Privacy」
    • 點選「Clear All」
  • 掃瞄、修復、重組磁碟
  • 其他動作(我沒玩過,歡迎有用過的談談心得)
    • 清除不用的右鍵選單與註冊表內容
    • 找清除軟體來幫你清

相關連結

管理Windows遠端桌面工具-MMC

相信有很多人都已經會使用Windows提供的遠端桌面了吧(如果還不會請參考 Windows初始安裝設定或是在 Windows XP 中安裝遠端桌面網路連線)

不過如果你常常要連到很多台不一樣的電腦,甚至在這些電腦游移,或許你會像我一樣,覺得切換起來有些麻煩吧~

最近我發現其實微軟有提供了一個工具,是MMC(Microsoft Management Console),底下有一個嵌入的元件叫tsmmc,基本上就能夠解決切換還有管理的問題囉

在哪

這個系統管理工具其實是在Windows 2003的光碟中有附安裝程式,但因為大多數的一般使用者都用XP,所以一直沒注意到~

在這裡告訴大家兩個取得的方式

安裝完後就可以使用了

怎麼用

你可以選【開始】→【執行】,輸入【tsmmc.msc】(或是執行【%systemroot%\system32\tsmmc.msc】),就可以看到以下視窗

然後就可以加入你想遠端連線的電腦資訊

連線

然後就可是看到結果了(預設會把解析度調成視窗大小,當然這都是可設定的)

依此方式可以加很多台遠端連線~

設定完後,你可以把這個連線的清單另存在桌面,下次就開那個設定檔就好了~

結論

有了這樣的工具,連很多電腦~要切來切去~都隨你切啦~

還有一點,就是Windows 2003 server原本如果用一般的遠端連線,它會另外開啟一個相同使用者名稱的使用者,也就會跑出好多個終端機連線~

但用了這個管理工具,它就變的跟XP的遠端連線一樣,會登出電腦前的使用者,讓你控制~這點倒解開了我多年的疑惑~

針對XP預設的遠端桌面程式,精由網友提供的資訊(感謝Gary),如果想要如同連XP般連到2003的桌面,而不是使用終端機的方式連線,只要改在呼叫程式前加上/console 的參數就行了

具體方法有兩個

  • 開始→執行→【mstsc /console】
  • 將開始→程式集→附屬應用程式→通訊→【遠端桌面連線】的捷徑複製一份放桌面,然後修改目標到【%SystemRoot%\system32\mstsc.exe /console】就可以用它開啟了

當然tsmmc中也可以取消掉預設的【連線到主控台】,這樣在連線時就會以終端機的方式連線了。

不過經過我測試,有的電腦用這樣的遠端好像連線會有問題,應該是作業系統的版本差異問題,大多數都OK的啦~

相關連結

用VB.Net寫的RSS Feed產生函式

我自己是很喜歡用RSS的服務的人,所以寫網站或是做一些事時常會想到要弄個RSS Feed,最起碼自己會用的到~

不過VB中並沒有直接提供RSS Feed的產生函式,國外有些網站好像有提供類似的東西,不過不是要註冊就是有些複雜,所以我就自己寫了一個~

作法

我原本是用FileIO那篇的寫文字檔的方式,用比較笨的方法產生RSS Feed~

不過後來我改用以下的內容,將RSS的內容,以Xml.XmlDocument這個類別來產生XML的結構,順便學習在VB.Net下怎麼自己產生XML結構,並且它會自己將HTML編碼的問題解決

RSS 2.0的規格則是參考RSS 2.0 Specification中的規定,來設計RSS feed的元素,不過我剔除掉了一些我覺得沒用或是我看不出來功能的標籤,來產生結果

模組程式碼

Imports System
Module RSSGenModule
   ''' 
   ''' RSSGenerator V1.0 is builded by Allen
   ''' Please get the newest information at
   ''' http://allen080.blogspot.com/
   ''' 
   Public Class RSSGenerator
       Public Sub createRSS(ByRef rssfeed As RSSFeed, ByVal path As String)
           'RSS 2.0 specification is Reference at
           'http://www.rssboard.org/rss-specification/
           Dim x As New Xml.XmlDocument
           x.LoadXml("" + "" + "")

           Dim channel As Xml.XmlElement = x.CreateElement("channel")
           x.DocumentElement.AppendChild(channel)

           Dim element As Xml.XmlElement
           Dim subElement As Xml.XmlElement
           'set channel start
           element = x.CreateElement("title")
           channel.AppendChild(element)
           element.InnerText = rssfeed.title
           If Not rssfeed.link Is Nothing Then
               element = x.CreateElement("link")
               channel.AppendChild(element)
               element.InnerText = rssfeed.link
           End If
           If Not rssfeed.description Is Nothing Then
               element = x.CreateElement("description")
               channel.AppendChild(element)
               element.InnerText = rssfeed.description
           End If
           If Not rssfeed.language Is Nothing Then
               element = x.CreateElement("language")
               channel.AppendChild(element)
               element.InnerText = rssfeed.language
           End If
           If Not rssfeed.copyright Is Nothing Then
               element = x.CreateElement("copyright")
               channel.AppendChild(element)
               element.InnerText = rssfeed.copyright
           End If
           If Not rssfeed.managingEditor Is Nothing Then
               element = x.CreateElement("managingEditor")
               channel.AppendChild(element)
               element.InnerText = rssfeed.managingEditor
           End If

           If Not rssfeed.webMaster Is Nothing Then
               element = x.CreateElement("webMaster")
               channel.AppendChild(element)
               element.InnerText = rssfeed.webMaster
           End If

           element = x.CreateElement("pubDate")
           channel.AppendChild(element)
           element.InnerText = (rssfeed.pubDate.AddHours(-8)).ToString("r")

           element = x.CreateElement("lastBuildDate")
           channel.AppendChild(element)
           element.InnerText = (rssfeed.lastBuildDate.AddHours(-8)).ToString("r")

           If Not rssfeed.category Is Nothing Then
               element = x.CreateElement("category")
               channel.AppendChild(element)
               element.InnerText = rssfeed.category
           End If
           If Not rssfeed.generator Is Nothing Then
               element = x.CreateElement("generator")
               channel.AppendChild(element)
               element.InnerText = rssfeed.generator
           End If
           If Not rssfeed.docs Is Nothing Then
               element = x.CreateElement("docs")
               channel.AppendChild(element)
               element.InnerText = rssfeed.docs
           End If


           If Not rssfeed.image Is Nothing Then
               element = x.CreateElement("image")
               channel.AppendChild(element)
               'set image start
               If Not rssfeed.image.title Is Nothing Then
                   subElement = x.CreateElement("title")
                   element.AppendChild(subElement)
                   subElement.InnerText = rssfeed.image.title
               End If
               If Not rssfeed.image.link Is Nothing Then
                   subElement = x.CreateElement("link")
                   element.AppendChild(subElement)
                   subElement.InnerText = rssfeed.image.link
               End If
               subElement = x.CreateElement("url")
               element.AppendChild(subElement)
               subElement.InnerText = rssfeed.image.url
               If Not rssfeed.image.description Is Nothing Then
                   subElement = x.CreateElement("description")
                   element.AppendChild(subElement)
                   subElement.InnerText = rssfeed.image.description
               End If
               'set image end
           End If
           If Not rssfeed.itmes Is Nothing Then
               For Each item As RSSElement In rssfeed.itmes
                   element = x.CreateElement("item")
                   channel.AppendChild(element)
                   'set item start
                   subElement = x.CreateElement("title")
                   element.AppendChild(subElement)
                   subElement.InnerText = item.title
                   If Not item.link Is Nothing Then
                       subElement = x.CreateElement("link")
                       element.AppendChild(subElement)
                       subElement.InnerText = item.link
                   End If
                   If Not item.description Is Nothing Then
                       subElement = x.CreateElement("description")
                       element.AppendChild(subElement)
                       subElement.InnerText = item.description
                   End If
                   If Not item.author Is Nothing Then
                       subElement = x.CreateElement("author")
                       element.AppendChild(subElement)
                       subElement.InnerText = item.author
                   End If
                   If Not item.category Is Nothing Then
                       subElement = x.CreateElement("category")
                       element.AppendChild(subElement)
                       subElement.InnerText = item.category
                   End If
                   If Not item.comments Is Nothing Then
                       subElement = x.CreateElement("comments")
                       element.AppendChild(subElement)
                       subElement.InnerText = item.comments
                   End If
                   If Not item.guid Is Nothing Then
                       subElement = x.CreateElement("guid")
                       subElement.SetAttribute("isPermaLink", "false")
                       element.AppendChild(subElement)
                       subElement.InnerText = item.guid
                   End If

                   subElement = x.CreateElement("pubDate")
                   element.AppendChild(subElement)
                   subElement.InnerText = (item.pubDate.AddHours(-8)).ToString("r")
                   'set item end
               Next
           End If
           'set channel end

           'write to file
           Dim settings As New Xml.XmlWriterSettings()
           settings.Indent = True
           settings.IndentChars = "    "
           settings.Encoding = System.Text.Encoding.UTF8
           Using writer As Xml.XmlWriter = Xml.XmlWriter.Create(path, settings)
               x.WriteTo(writer)
               writer.Flush()
           End Using
       End Sub
   End Class

   Public Class RSSElement
       Private _title As String
       Private _link As String
       Private _description As String
       Private _author As String
       Private _category As String
       Private _comments As String
       Private _guid As String
       Private _pubDate As Date
       Public Property pubDate() As Date
           Get
               Return _pubDate
           End Get
           Set(ByVal value As Date)
               _pubDate = value
           End Set
       End Property

       Public Property guid() As String
           Get
               Return _guid
           End Get
           Set(ByVal value As String)
               _guid = value
           End Set
       End Property

       ''' 
       ''' 回應的URL
       ''' 
       Public Property comments() As String
           Get
               Return _comments
           End Get
           Set(ByVal value As String)
               _comments = value
           End Set
       End Property
       Public Property category() As String
           Get
               Return _category
           End Get
           Set(ByVal value As String)
               _category = value
           End Set
       End Property

       ''' 
       ''' E-Mail
       ''' 
       Public Property author() As String
           Get
               Return _author
           End Get
           Set(ByVal value As String)
               _author = value
           End Set
       End Property

       Public Property description() As String
           Get
               Return _description
           End Get
           Set(ByVal value As String)
               _description = value
           End Set
       End Property

       Public Property title() As String
           Get
               Return _title
           End Get
           Set(ByVal value As String)
               _title = value
           End Set
       End Property
       Public Property link() As String
           Get
               Return _link
           End Get
           Set(ByVal value As String)
               _link = value
           End Set
       End Property
   End Class

   Public Class RSSImage
       Private _title As String
       Private _link As String
       Private _url As String
       Private _description As String
       Public Property description() As String
           Get
               Return _description
           End Get
           Set(ByVal value As String)
               _description = value
           End Set
       End Property

       Public Property url() As String
           Get
               Return _url
           End Get
           Set(ByVal value As String)
               _url = value
           End Set
       End Property

       Public Property link() As String
           Get
               Return _link
           End Get
           Set(ByVal value As String)
               _link = value
           End Set
       End Property

       Public Property title() As String
           Get
               Return _title
           End Get
           Set(ByVal value As String)
               _title = value
           End Set
       End Property
   End Class

   Public Class RSSFeed
       Private _title As String
       Private _link As String
       Private _description As String
       Private _language As String = "zh-tw"
       Private _copyright As String
       Private _managingEditor As String
       Private _webMaster As String
       Private _guid As String
       Private _pubDate As Date = Now
       Private _lastBuildDate As Date = Now
       Private _category As String
       Private _generator As String
       Private _docs As String = "http://www.rssboard.org/rss-specification"
       Private _image As RSSImage
       Private _items As ArrayList

       ''' 
       ''' 元素型態是RSSElement
       ''' 
       Public Property itmes() As ArrayList
           Get
               Return _items
           End Get
           Set(ByVal value As ArrayList)
               _items = value
           End Set
       End Property
       Public Property image() As RSSImage
           Get
               Return _image
           End Get
           Set(ByVal value As RSSImage)
               _image = value
           End Set
       End Property

       ''' 
       ''' URL
       ''' 
       Public Property docs() As String
           Get
               Return _docs
           End Get
           Set(ByVal value As String)
               _docs = value
           End Set
       End Property

       Public Property generator() As String
           Get
               Return _generator
           End Get
           Set(ByVal value As String)
               _generator = value
           End Set
       End Property

       Public Property category() As String
           Get
               Return _category
           End Get
           Set(ByVal value As String)
               _category = value
           End Set
       End Property

       Public Property lastBuildDate() As Date
           Get
               Return _lastBuildDate
           End Get
           Set(ByVal value As Date)
               _lastBuildDate = value
           End Set
       End Property
       Public Property pubDate() As Date
           Get
               Return _pubDate
           End Get
           Set(ByVal value As Date)
               _pubDate = value
           End Set
       End Property

       Public Property guid() As String
           Get
               Return _guid
           End Get
           Set(ByVal value As String)
               _guid = value
           End Set
       End Property

       ''' 
       ''' E-Mail
       ''' 
       Public Property managingEditor() As String
           Get
               Return _managingEditor
           End Get
           Set(ByVal value As String)
               _managingEditor = value
           End Set
       End Property

       ''' 
       ''' E-Mail
       ''' 
       Public Property webMaster() As String
           Get
               Return _webMaster
           End Get
           Set(ByVal value As String)
               _webMaster = value
           End Set
       End Property

       Public Property copyright() As String
           Get
               Return _copyright
           End Get
           Set(ByVal value As String)
               _copyright = value
           End Set
       End Property

       Public Property language() As String
           Get
               Return _language
           End Get
           Set(ByVal value As String)
               _language = value
           End Set
       End Property

       Public Property description() As String
           Get
               Return _description
           End Get
           Set(ByVal value As String)
               _description = value
           End Set
       End Property

       Public Property title() As String
           Get
               Return _title
           End Get
           Set(ByVal value As String)
               _title = value
           End Set
       End Property
       Public Property link() As String
           Get
               Return _link
           End Get
           Set(ByVal value As String)
               _link = value
           End Set
       End Property
   End Class

End Module

使用方法

這個模組中主要有4個類別,分別是

  • RSSFeed:整個RSS的資料都存在這裡面,如果沒有被設定到的屬性,就不會被寫入檔案中(日期除外)
  • RSSImage:用來顯示Logo的資訊,如果沒有Logo就不要把它設定給RSSFeed就好了
  • RSSElement:用來存每一筆新資訊的地方,在RSSFeed中是被ArrayList存起來的
  • RSSGenerator:將路徑與RSSFeed交給其中的createRSS函式,就能產生一個RSS feed檔

使用範例

            Dim rssfeed As New RSSFeed
           rssfeed.title = title
           rssfeed.link = url
           rssfeed.description = title
           rssfeed.generator = "倫倫3號"
           rssfeed.webMaster = "allen080+Tech@gmail.com"
           Dim rssimage As New RSSImage
           rssfeed.image = rssimage
           rssimage.title = title
           rssimage.link = url
           rssimage.url = url + "images/fslogo.jpg"
           rssfeed.itmes = New ArrayList
           Dim notes As ArrayList = gbdatas
           For Each item As GuestBookData In notes
               Dim rsselement As New RSSElement
               rsselement.title = item.title
               rsselement.author = item.eMail + " (" + item.name + ")"
               rsselement.link = item.url
               rsselement.description = item.content
               rsselement.pubDate = item.time
               rsselement.guid = item.url
               rssfeed.itmes.Add(rsselement)
           Next

           Dim rssgen As New RSSGenerator
           rssgen.createRSS(rssfeed, path)

總結

有這樣的一個類別就可以很快的產生出屬於自己的RSS Feed,當然這個xml檔要放在網頁伺服器上,我通常是用IIS就解決了~

完成的檔案可以透過Feed Validator for Atom and RSS這樣的網站來做驗證,不過如果只是一些小警告、小錯誤不理他也沒關係,只要你的RSS Reader不會讀不出來就好了

寫完這個RSS產生函式,如果有空我會找時間看看Atom的不同,如果有必要,也會寫Atom的版本~

參考連結

有Web 2.0概念的網站-Tagomatic-相關資料搜尋服務

倫倫常在網路上試用許多有Web 2.0概念的網站,大多數好用,成功的都有許多人推薦了~

不過Tagomatic這個網站是我第一次看到,概念很簡單,但很有趣且有用,簡單來說就是相關資料的集體智慧整理,以下我來談談它到底能做什麼

引述

  • The Tagomatic is an index of Bands, Movies, Books, and Web Sites that is void of genres. Everything is indexed by what it is similar to. The community can tag any item as being similar to any other item to create a more useful index of entertainment media. Help us help each other.

功能簡述

Tagomatic 是一個樂團、電影、書、網站的索引,所有的資訊都用它的相關資料所描述,而這些相關的資料都來自於

試用過程

我個人稍微玩了一下,網站的關連對我而言最有吸引力~

例如我在找類似http://calculatepie.com/的網站(這個網站的的功用類似我【用 Psiphon 突破網站封鎖】這篇)~

所以就輸入了calculatepie.com,然後選我要搜尋Web Sites,這時就出現了一些類似的網站網址~

然後我就可以依照這些網址找到類似的服務~並且為它們加減分~

如果我覺得有相關的網址,也可以選【Tag a SIMILAR web site】來加入~

心得

大概是才上線不夠久,所以還沒辦法呈現它的威力,不過如果這樣的網站像del.icio.us一般受歡迎,那以後或許找東西又多了一種簡單的方式~

Web 2.0的網站從2005年直到現在,不斷湧現,有人報樂觀,有人抱悲觀的態度在看這件事,也有許多人想盡辦法從中謀利,目前為畢業衝刺的我,沒辦法直接跳入這個洪流,但我覺得除了跳進去外,各個網站的思考、經營模式都十分值得我觀察學習,就我現在的所看到的狀況,2007年應該會像所謂的.com泡沫化前夕一樣,網路上號稱Web 2.0的網路服務會多到使用者不知該用哪個,懶惰又容易被分散的使用者們的支持下,有多少服務能存活呢?拭目以待~

這裡是關於技術的手札~

也歡迎大家到

倫與貓的足跡



到噗浪來

關心一下我唷!
by 倫
 
Copyright 2009 倫倫3號Beta-Log All rights reserved.
Blogger Templates created by Deluxe Templates
Wordpress Theme by EZwpthemes