Cannot scripting Windows 7 offline files synchronization with WMI Class "Win32_OfflineFilesCache"

Respondido Cannot scripting Windows 7 offline files synchronization with WMI Class "Win32_OfflineFilesCache"

  • sexta-feira, 4 de fevereiro de 2011 10:22
     
      Contém Código

    Hello,

    We will replace our notebook clients from Windows XP Pro with Windows 7 Enterprise. Today in the home office this clients connects over a VPN script to our company LAN. After a successfuly VPN connection the script forces a synchronisation of the Windows XP offline files with the command line tool "csccmd.exe" (http://support.microsoft.com/kb/884739/en-us). This tool doesn't work since Windows Vista.

    I'll try to use the new Offline files WMI Provider (http://msdn.microsoft.com/en-us/library/bb309182(v=vs.85).aspx) to make a new script in VBS or C#.NET. I found two vbscripts examples (CscSync.vbs – Sync a particular UNC path and CscSyncAll.vbs – Sync the entire Offline Files cache) but they doesn't work. No error message received.

    When I use the the methods TransitionOffline or TransitionOnline in the same way as below it works.

    Do anyone know how to use the WMI Provider or the Offline files API?

    Regards, Mike

     

    My example in C#.Net that doesn't work:

    // Offline files flags
    //const int OfflineFilesSyncControlFlagFillSparse    = 0x00000001;
    const int OfflineFilesSyncControlFlagSyncIn = 0x00000002;
    const int OfflineFilesSyncControlFlagSyncOut = 0x00000004;
    const int OfflineFilesSyncControlFlagPinNewFiles = 0x00000008;
    //const int OfflineFilesSyncControlFlagPinLinkTargets  = 0x00000010;
    const int OfflineFilesSyncControlFlagPinForUser = 0x00000020;
    //const int OfflineFilesSyncControlFlagPinForUser_Policy = 0x00000040;
    //const int OfflineFilesSyncControlFlagPinForAll     = 0x00000080;
    //const int OfflineFilesSyncControlFlagAsyncProgress   = 0x00000400;
    const int OfflineFilesSyncControlFlagInteractive = 0x00000800;
    //const int OfflineFilesSyncControlFlagConsole      = 0x00001000;
    //const int OfflineFilesSyncControlFlagSkipSuspendedDirs = 0x00002000;
    //const int OfflineFilesSyncControlFlagBackground    = 0x00010000;
    
    // Folder for Windows offline files ynchronisation (My dokuments on net drive)
    string[] Paths = new string[] { System.Environment.GetEnvironmentVariable("HOMESHARE") + "\\Eigene Dateien" };
    
    try
    {
      ManagementClass classInstance = new ManagementClass("Win32_OfflineFilesCache");
    
      // Get parameters for method
      ManagementBaseObject inParams = classInstance.GetMethodParameters("Synchronize");
    
      // Set parameters
      inParams["Flags"] = OfflineFilesSyncControlFlagSyncIn +
                OfflineFilesSyncControlFlagSyncOut +
                OfflineFilesSyncControlFlagPinNewFiles +
                OfflineFilesSyncControlFlagPinForUser +
                OfflineFilesSyncControlFlagInteractive;
      inParams["Paths"] = Paths;
    
      // Execute the method and obtain the return values.
      ManagementBaseObject outParams = classInstance.InvokeMethod("Synchronize", inParams, null);
    }
    catch (Exception err)
    {
      Console.WriteLine("An error occurred while trying to execute the WMI method: " + err.Message);
    }
    

Todas as Respostas

  • sábado, 12 de fevereiro de 2011 23:58
    Moderador
     
     Respondido

    This help any?

    http://blogs.technet.com/b/heyscriptingguy/archive/2009/06/02/how-can-i-work-with-the-offline-files-feature-in-windows.aspx

    Sorry, I don't understand what you're trying to accomplish, but don't take that as meaning you haven't explained it properly...

  • segunda-feira, 21 de fevereiro de 2011 10:11
     
     

    Hi Marco,

    The goal of the script is a manual synchronization of all files in the Offline Files cache. But the Methode of the Offline files WMI Provider "Win32_OfflineFilesCache.Synchronize" doesen't work in our Windows 7 environment. The files are not synchronized, and unfortunately I get no error message.

    The examples from your link works correctly, but the latter method Win32_OfflineFilesCache.Synchronize" has no function.

    I am currently in contact with Microsoft support and hope to solve the problem with their help. The earliest surviving example of a synchronization scripts has not worked. Once I have more information, I'll report it here.

  • terça-feira, 19 de abril de 2011 07:55
     
     
    Any update on this ? I have the same issue.
  • quarta-feira, 27 de abril de 2011 09:24
     
     
    Hello, We had opend a case at Microsoft premier support who makes us a C# program (offline files API: http://msdn.microsoft.com/en-us/library/bb530660(VS.85).aspx) or a vbscript (based from WMI provider). The MS Engineer decided itself for C# therefore I think the WMI provider doesn't work right. I'm sorry but I can't give you the final C# project. Please open a case at Microsoft premier support. Regards, Mike
  • quinta-feira, 15 de março de 2012 10:37
     
     Resposta Proposta

    The MS Storage Team published a VBScript that triggers synchronization for a UNC path:

    http://blogs.technet.com/b/filecab/archive/2007/04/26/cscsync-vbs-sync-a-particular-unc-path.aspx

    It uses WMI and works well on Windows 7 x64 SP1.


    Author of SetACL | web: http://helgeklein.com | Twitter: @HelgeKlein

    • Sugerido como Resposta HelgeKleinMVP quinta-feira, 15 de março de 2012 10:38
    •