Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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;
- using System.Security.Principal;
- using IWshRuntimeLibrary;
- using System.IO;
- // decrypted = CryptorEngine.Decrypt(encrypted, true);
- namespace runv2
- {
- public partial class Form1 : Form
- {
- bool isElevated = new WindowsPrincipal(WindowsIdentity.GetCurrent()).IsInRole(WindowsBuiltInRole.Administrator);
- string DesktopFolder = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
- runv2.Login pLogin = new Login();
- private string pUser = string.Empty, pPass = string.Empty;
- public Form1()
- {
- getLoginFromFile();
- LoadAll();
- //pLogin.ShowDialog();
- InitializeComponent();
- this.Refresh();
- //FileDialog();
- }
- void Start(string fPath)
- {
- StreamReader sr = new StreamReader(@".\login.txt");
- string domain = "";
- try
- {
- Process p = RunAs.StartProcess(pUser, domain, pPass, "\"" + fPath);
- }
- catch (Win32Exception w32e)
- {
- MessageBox.Show(w32e.ToString());// The process didn't start.
- }
- }
- void FileDialog()
- {
- string fPath = string.Empty;
- string fFilename = string.Empty;
- string decrypted = string.Empty;
- string encrypted = string.Empty;
- OpenFileDialog openFileDialog1 = new OpenFileDialog();
- openFileDialog1.Title = "Anwendung aussucheN";
- openFileDialog1.InitialDirectory = @"D:\";
- openFileDialog1.Filter = "Anwendungen (*.exe)|*.exe";
- if (openFileDialog1.ShowDialog() == DialogResult.OK)
- fPath = openFileDialog1.FileName;
- fFilename = Path.GetFileNameWithoutExtension(fPath);
- if (fFilename != "")
- createLink(fPath, fFilename);
- }
- void createLink(string fPath,string fFilename)
- {
- if (!Directory.Exists(Application.StartupPath + "\\Links\\"))
- {
- Directory.CreateDirectory(Application.StartupPath + "\\Links\\");
- }
- WshShell shell = new WshShell();
- IWshShortcut link = (IWshShortcut)shell.CreateShortcut(Application.StartupPath+"\\Links\\"+fFilename+".lnk");
- link.TargetPath = fPath;
- link.Save();
- }
- string[] getLogin()
- {
- string account, password;
- string[] login = new string[2];
- account = pLogin.Acc;
- password = pLogin.Pw;
- login[0] = account;
- login[1] = password;
- return login;
- }
- string[] encrypt()
- {
- string encrypted_acc = string.Empty, encrypted_pw = string.Empty;
- string[] encrypted_array = new string[2];
- string[] login_array = new string[2];
- login_array = getLogin();
- if (encrypted_acc != null && encrypted_pw != null)
- {
- encrypted_acc = CryptorEngine.Encrypt(login_array[0], true);
- encrypted_pw = CryptorEngine.Encrypt(login_array[1], true);
- encrypted_array[0] = encrypted_acc;
- encrypted_array[1] = encrypted_pw;
- }
- return encrypted_array;
- }
- private void button1_Click(object sender, EventArgs e)
- {
- string[] encrypted = encrypt();
- StreamWriter sw = new StreamWriter(@".\login.txt");
- foreach (string pEnc in encrypted)
- {
- sw.WriteLine(pEnc);
- }
- sw.Close();
- MessageBox.Show("Login-Daten gespeichert!", "Success!", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- void getLoginFromFile()
- {
- if (!System.IO.File.Exists(@".\login.txt"))
- {
- StreamReader sr = new StreamReader(@".\login.txt");
- pUser = sr.ReadLine();
- pPass = sr.ReadLine();
- }
- }
- private void button2_Click(object sender, EventArgs e)
- {
- Start("as");
- }
- void LoadAll()
- {
- string[] filePaths = Directory.GetFiles(@".\Links\", "*.lnk");
- listBox1.Items = new List<string>();
- foreach(string Path in filePaths)
- {
- listBox1.Items.Add(Path);
- }
- //foreach()
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment