0

私はVB.Netを使用してExcelファイル回復プログラムを作成しています。これは、 Microsoftが推奨する方法を収集してアクセスするのに便利な場所を目指しています。私のおそらく不器用で、エラーがいっぱいで、十分なクリーンアップコードがないことに興味がある場合は、ここにあります:http: //pastebin.com/v4GgDteY。グラフマクロテーブルのリカバリはまだテストしていませんが、基本的な機能は機能しているようです。

シャドウコピーサービスがオンで、以前のコピーがある場合、VistaおよびWindows7のユーザーはアプリケーション内のファイルの以前のバージョンのリストを提供されることで恩恵を受けることができると思いました。どうすればよいですか?

私はたくさんのウェブページを見ましたが、簡単にコードをベビーベッドに入れることができませんでした。私が推測する1つの可能性は、シェルを介してvssadminを使用することですが、それはかなり面倒です。以前のバージョンのプロパティシートのようなダイアログボックスを表示して、ユーザーが以前のバージョンの1つを選択できるようにしたいだけです。プログラムでコンテキストメニューと[以前のバージョンの選択を復元]を呼び出すことで、シェルを介して以前のバージョンのプロパティシートを表示できたと思いますが、VistaHomeBasicおよびPremiumユーザー向けのリストも提供できるようにしたいと思います。以前のバージョンがまだ存在しているように見えても、そのタブにアクセスできます。さらに、可能であれば、XPユーザーに同じ機能を提供したいと思いますが、XPではシステムファイルのみがシャドウコピーに含まれていると確信しています。

Shadow Copy ServiceでMSDNを確認し、すべてのページを確認しました。また、AlphaVSSとAlphaFS、およびすべてのコメントも確認しました。AlphaVssとAlphFSを使用して、次のことを行う必要があると思いますか?

  1. コンピューターに存在するスナップショット/復元ポイントのリストを確認します。
  2. それらのスナップショットをマウントします。
  3. マウントされたボリューム内で、ユーザーが回復したいExcelファイルに移動し、それらのパスのリストを作成します。
  4. パスのリストが手元にあるので、ある種のdiffプログラムと比較して、ファイルのシャドウコピーを元のファイルと比較してください。
  5. リカバリターゲットとは異なるシャドウコピーの最も若いバージョンまたは最も古いバージョン(重要ではないと思います)を引き出します。
  6. 異なることが判明したファイルのバージョンをリストします。

これは面倒で遅いように見えますが、おそらく最も速い方法です。私は今行く方法であるいくつかの確認が必要です。

4

1 に答える 1

0

私はついに先に進んでコーディングを始めることにしました。コードを高速化するための提案、またはリカバリファイルのターゲットとは異なることが判明したファイルをどうするかについて提案してください。AlphaVSSとAlphaFSでこれを行う簡単な方法はありますか?

Private Sub Button1_Click_2(sender As System.Object, e As System.EventArgs) Handles Button1.Click

    'Find out the number of vss shadow snapshots (restore 
    'points). All shadows apparently have a linkable path 
    '\\?\GLOBALROOT\Device\HarddiskVolumeShadowCopy#,
    'where # is a simple one, two or three digit integer.
    Dim objProcess As New Process()
    objProcess.StartInfo.UseShellExecute = False
    objProcess.StartInfo.RedirectStandardOutput = True
    objProcess.StartInfo.CreateNoWindow = True
    objProcess.StartInfo.RedirectStandardError = True
    objProcess.StartInfo.FileName() = "vssadmin"
    objProcess.StartInfo.Arguments() = "List Shadows"
    objProcess.Start()

    Dim burp As String = objProcess.StandardOutput.ReadToEnd
    Dim strError As String = objProcess.StandardError.ReadToEnd()
    objProcess.WaitForExit()
    Dim xnum As Integer = 0
    Dim counterVariable As Integer = 1
    ' Call Regex.Matches method.
    Dim matches As MatchCollection = Regex.Matches(burp, _
                            "HarddiskVolumeShadowCopy")
    ' Loop over matches.
    For Each m As Match In matches
        xnum = xnum + 1
        'At the max xnum + 1 is the number of shadows that exist
    Next
    objProcess.Close()

    Do
        'Here we make symbolic links to all the shadows, one at a time 
        'and loop through until all shadows are exposed as folders in C:\.
        Dim myProcess As New Process()
        myProcess.StartInfo.FileName = "cmd.exe"
        myProcess.StartInfo.UseShellExecute = False
        myProcess.StartInfo.RedirectStandardInput = True
        myProcess.StartInfo.RedirectStandardOutput = True
        myProcess.StartInfo.CreateNoWindow = True
        myProcess.Start()
        Dim myStreamWriter As StreamWriter = myProcess.StandardInput
        myStreamWriter.WriteLine("mklink /d C:\shadow" & counterVariable _
            & " \\?\GLOBALROOT\Device\HarddiskVolumeShadowCopy" _
            & counterVariable & "\")
        myStreamWriter.Close()
        myProcess.WaitForExit()
        myProcess.Close()

        ' Here I compare our recovery target file against the shadow copies
        Dim sFile As String = PathTb.Text
        Dim sFileShadowPath As String = "C:\shadow" & _
            counterVariable & DelFromLeft("C:", sFile)
        Dim jingle As New Process()
        jingle.StartInfo.FileName = "cmd.exe"
        jingle.StartInfo.UseShellExecute = False
        jingle.StartInfo.RedirectStandardInput = True
        jingle.StartInfo.RedirectStandardOutput = True
        jingle.StartInfo.CreateNoWindow = True
        jingle.Start()
        Dim jingleWriter As StreamWriter = jingle.StandardInput
        jingleWriter.WriteLine("fc """ & sFile & """ """ _
                               & sFileShadowPath & """")
        jingleWriter.Close()
        jingle.WaitForExit()
        Dim jingleReader As StreamReader = jingle.StandardOutput
        Dim JingleCompOut As String = jingleReader.ReadToEnd
        jingleReader.Close()
        jingle.WaitForExit()
        jingle.Close()
        Dim jingleBoolean As Boolean = JingleCompOut.Contains( _
            "no differences encountered").ToString
        If jingleBoolean = "True" Then
            MsgBox(jingleBoolean)
        Else
            'I haven't decided what to do with the paths of 
            'files that are different from the recovery target.
            MsgBox("No")
        End If

        counterVariable = counterVariable + 1
    Loop Until counterVariable = xnum + 1

End Sub
于 2011-12-14T20:09:48.737 に答える