/// <summary> /// 重启。 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void toolStripMenuItemRestart_Click(object sender, EventArgs e) { if (MessageBox.Show("确定要重启选中的机机吗?", "确认", MessageBoxButtons.OKCancel) == DialogResult.OK) { foreach (ListViewItem lvi in listView1.SelectedItems) { try { using (SessionCommandHelper helper = new SessionCommandHelper(lvi.Tag as ClientData)) { await helper.StartAsync("shutdown", "-r -t 0 -f"); } } catch (Exception ex) { MessageBox.Show(ex.Message); } } } }
/// <summary> /// 注销。 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void toolStripMenuItemLock_Click(object sender, EventArgs e) { if (MessageBox.Show("确定要注销选中的机机吗?", "确认", MessageBoxButtons.OKCancel) == DialogResult.OK) { foreach (ListViewItem lvi in listView1.SelectedItems) { try { ClientData client = lvi.Tag as ClientData; using (SessionCommandHelper helper = new SessionCommandHelper(client)) { await helper.StartAsync("rundll32.exe", "user32.dll,LockWorkStation"); } } catch (Exception ex) { MessageBox.Show(ex.Message); } } } }