Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. VBScript to C#

VBScript to C#

Scheduled Pinned Locked Moved C#
csharpcomtutorialquestion
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    CyberKewl
    wrote on last edited by
    #1

    I'm trying to write an app that handles system restore related stuff and would like to know how to convert the VBScript(s) in the following page into C# equivalent: http://support.microsoft.com/default.aspx?scid=KB;en-us;295299&

    M 1 Reply Last reply
    0
    • C CyberKewl

      I'm trying to write an app that handles system restore related stuff and would like to know how to convert the VBScript(s) in the following page into C# equivalent: http://support.microsoft.com/default.aspx?scid=KB;en-us;295299&

      M Offline
      M Offline
      Mike Dimmick
      wrote on last edited by
      #2

      Look at the System.Management.ManagementClass class. My quick stab looks like:

      ManagementClass mc =
      new ManagementClass( @"\\.\root\default:Systemrestore" );
      mc.Get();

      mc.InvokeMethod(
      "CreateRestorePoint",
      new object[] { "this is a test", 0, 100 }
      );

      However, this didn't appear to do anything - but then I may be misunderstanding the underlying API.

      C 1 Reply Last reply
      0
      • M Mike Dimmick

        Look at the System.Management.ManagementClass class. My quick stab looks like:

        ManagementClass mc =
        new ManagementClass( @"\\.\root\default:Systemrestore" );
        mc.Get();

        mc.InvokeMethod(
        "CreateRestorePoint",
        new object[] { "this is a test", 0, 100 }
        );

        However, this didn't appear to do anything - but then I may be misunderstanding the underlying API.

        C Offline
        C Offline
        CyberKewl
        wrote on last edited by
        #3

        Thanks. It works (at least on WinXP) but i'm wondering how to get the other one to work : set SRP = getobject("winmgmts:\\.\root\default").InstancesOf ("systemrestore") for each Point in SRP msgbox point.creationtime & vbcrlf & point.description & vbcrlf & "Sequence Number= " & point.sequencenumber next

        M 1 Reply Last reply
        0
        • C CyberKewl

          Thanks. It works (at least on WinXP) but i'm wondering how to get the other one to work : set SRP = getobject("winmgmts:\\.\root\default").InstancesOf ("systemrestore") for each Point in SRP msgbox point.creationtime & vbcrlf & point.description & vbcrlf & "Sequence Number= " & point.sequencenumber next

          M Offline
          M Offline
          Mike Dimmick
          wrote on last edited by
          #4

          After a bit of trial and terror:

          ManagementScope scope =
          new ManagementScope( @"\\.\root\default" );
          scope.Connect();

          SelectQuery sq = new SelectQuery( "SystemRestore" );
          ManagementObjectSearcher mos =
          new ManagementObjectSearcher( scope, sq );

          foreach ( ManagementObject mo in mos.Get() )
          {
          Console.WriteLine(
          "{0}: {1}, sequence no {2}",
          mo[ "CreationTime" ],
          mo[ "Description" ],
          mo[ "SequenceNumber" ]
          );
          }

          When investigating a ManagementObject, you may find the Properties collection helpful.

          C 1 Reply Last reply
          0
          • M Mike Dimmick

            After a bit of trial and terror:

            ManagementScope scope =
            new ManagementScope( @"\\.\root\default" );
            scope.Connect();

            SelectQuery sq = new SelectQuery( "SystemRestore" );
            ManagementObjectSearcher mos =
            new ManagementObjectSearcher( scope, sq );

            foreach ( ManagementObject mo in mos.Get() )
            {
            Console.WriteLine(
            "{0}: {1}, sequence no {2}",
            mo[ "CreationTime" ],
            mo[ "Description" ],
            mo[ "SequenceNumber" ]
            );
            }

            When investigating a ManagementObject, you may find the Properties collection helpful.

            C Offline
            C Offline
            CyberKewl
            wrote on last edited by
            #5

            Thanks a lot! I'll put your name in the credits for this :)

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups