shutdown

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • iwdu15

    #1

    shutdown

    hi, how can i shtudown my computer after a certain program program exits, for
    examples i have this code

    Dim withevents defrag as new process
    Dim defragSI as new processstartinf o("C:\windows\s ystem32\dfrag.m sc")

    then i have a "defrag has exited" event, so how can i have my computer
    shutdown when this command executes?

    thanks!
  • Ken Tucker [MVP]

    #2
    Re: shutdown

    Hi,

    Free software components for C#, VB.NET and other .NET languages.


    Ken
    ---------------
    "iwdu15" <iwdu15@discuss ions.microsoft. com> wrote in message
    news:7602A689-416F-4529-91D5-40CDD419BB24@mi crosoft.com...
    hi, how can i shtudown my computer after a certain program program exits,
    for
    examples i have this code

    Dim withevents defrag as new process
    Dim defragSI as new processstartinf o("C:\windows\s ystem32\dfrag.m sc")

    then i have a "defrag has exited" event, so how can i have my computer
    shutdown when this command executes?

    thanks!


    Comment

    • Herfried K. Wagner [MVP]

      #3
      Re: shutdown

      "iwdu15" <iwdu15@discuss ions.microsoft. com> schrieb:[color=blue]
      > hi, how can i shtudown my computer after a certain program program exits,
      > for
      > examples i have this code
      >
      > Dim withevents defrag as new process
      > Dim defragSI as new processstartinf o("C:\windows\s ystem32\dfrag.m sc")
      >
      > then i have a "defrag has exited" event, so how can i have my computer
      > shutdown when this command executes?[/color]

      In addition to Ken's reply:

      \\\
      Dim p As Process = Process.Start(" C:\WINDOWS\SYST EM32\defrag.msc ")
      p.WaitForExit()
      ShutdownMachine ()
      ///

      --
      M S Herfried K. Wagner
      M V P <URL:http://dotnet.mvps.org/>
      V B <URL:http://classicvb.org/petition/>

      Comment

      • iwdu15

        #4
        Re: shutdown

        ok thanks but the problem is, defrag doesnt exit when it is finished
        defragging....h ow can i tell if it is done?

        Comment

        • Herfried K. Wagner [MVP]

          #5
          Re: shutdown

          "iwdu15" <iwdu15@discuss ions.microsoft. com> schrieb:[color=blue]
          > ok thanks but the problem is, defrag doesnt exit when it is finished
          > defragging....h ow can i tell if it is done?[/color]

          Maybe you can find a solution by starting "defrag.exe " instead of the
          Management Console.

          --
          M S Herfried K. Wagner
          M V P <URL:http://dotnet.mvps.org/>
          V B <URL:http://classicvb.org/petition/>

          Comment

          • iwdu15

            #6
            Re: shutdown

            im doing that now, i switched to the defrag program and i can get to to
            defrag, but i dont kno how to tell if its done or not

            Comment

            • Herfried K. Wagner [MVP]

              #7
              Re: shutdown

              "iwdu15" <iwdu15@discuss ions.microsoft. com> schrieb:[color=blue]
              > im doing that now, i switched to the defrag program and i can get to to
              > defrag, but i dont kno how to tell if its done or not[/color]

              Did you already try 'Process.WaitFo rExit' as shown in my sample?

              --
              M S Herfried K. Wagner
              M V P <URL:http://dotnet.mvps.org/>
              V B <URL:http://classicvb.org/petition/>

              Comment

              • iwdu15

                #8
                Re: shutdown

                i would but defrag doesnt exit once its done defragging, so it would just sit
                there

                Comment

                • m.posseth

                  #9
                  Re: shutdown

                  hmm is this still about the auto defrag :-)

                  well i have some info , that might be of help

                  with these scripts found here you can do exactly what you want

                  Windows 2000 XP Disk Defragmenter Scheduler Scripts free from Compu-Docs, Schedule Script, Defrag, Defragment


                  if you want to write it pure in VB that is no problem ,,, as you only have
                  to start the defrag service , give it the main focus , send the apropriate
                  keys , and read the window caption to see if it is finished the parameters
                  can be found in these scripts


                  regards

                  Michel Posseth [MCP]



                  "iwdu15" <iwdu15@discuss ions.microsoft. com> wrote in message
                  news:C039A803-21A6-4362-AFA4-D93917BADFD5@mi crosoft.com...[color=blue]
                  >i would but defrag doesnt exit once its done defragging, so it would just
                  >sit
                  > there[/color]


                  Comment

                  Working...