Quantcast
Channel: Windows Forms General forum
Viewing all articles
Browse latest Browse all 12583

shutdown,logoff,restart windows from c#

$
0
0

hai my friends 

i asked a  question to et code for restart,logoff,shutdown windows from c# button 


i got a code like
==============================================
 private void button1_Click(object sender, EventArgs e)
        {
            //shutdown
            System.Diagnostics.Process.Start("shutdown.exe", "-s -t 0");
        }

        private void button2_Click(object sender, EventArgs e)
        {
            //restart
            System.Diagnostics.Process.Start("shutdown.exe", "-r -t 0");
        }

        private void button3_Click(object sender, EventArgs e)
        {
            //log off
            System.Diagnostics.Process.Start("shutdown.exe", "-I -t 0");
        }
==========================

whe i run this i got error message like

===============================
error win32Exeception was unhandled.
the system can not find the file specified
===================================

may be some dll or some refernce should add for this i don'nt know

after that  i got code in vb like
==================================
            ProcessProperties.FileName = (systemDirectory & "\shutdown.exe")
        Catch ex As Exception
        End Try
ProcessProperties.Arguments =", -s -t 30"       
ProcessProperties.WindowStyle = ProcessWindowStyle.Hidden
myProcess = Process.Start(ProcessProperties)

//======================================

still now problem is not solved

can anybody quote me corresponding code in c# for above vb

or give me correct code with refrence to (shutdown,restart,logogg from c# button)

regards

sadique


Viewing all articles
Browse latest Browse all 12583

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>