zoukankan      html  css  js  c++  java
  • C#对bat脚本文件的操作示例

    实现C#操作bat脚本文件

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.Diagnostics;//添加的

    namespace CSharpToScriptBat
    {
        public partial class frmMain : Form
        {
            public frmMain()
            {
                InitializeComponent();
            }

            private void btn1_Click(object sender, EventArgs e)
            {
                Process proc = null;
                try
                {
                    string targetDir = Application.StartupPath; ;//脚本文件的存放路径
                    proc = new Process();//实例化进程
                    proc.StartInfo.WorkingDirectory = targetDir;
                    proc.StartInfo.FileName = "setup.bat";
                    proc.StartInfo.Arguments = string.Format("10");//this is argument
                    proc.StartInfo.CreateNoWindow = false;
                    proc.Start();
                    proc.WaitForExit();
                    MessageBox.Show("ok");//
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Exception Occurred :{0},{1}", ex.Message,ex.StackTrace.ToString());
                }
            }
        }
    }

  • 相关阅读:
    【原创】使用开源libimobiledevice盗取iphone信息
    【原创】Arduino制作Badusb实践
    【原创】Aduino小车玩法全记录
    【原创】Arduino入门基础知识总结
    【原创】Arduino、arm、树莓派与单片机
    【原创】PM3破解IC卡记录
    【转】反编译D-Link路由器固件程序并发现后门
    DDOS分布式拒绝服务
    XSS 初识
    针对企业级别渗透测试流程
  • 原文地址:https://www.cnblogs.com/jife/p/3321999.html
Copyright © 2011-2022 走看看