Code Monkey home page Code Monkey logo

vexec's Introduction

vExec

proof of concept

Initial work on a C# WMI port for interactive remote command execution

Allows running of net use command with network resources available to logged on user

####Example

// Instantiation
vExec ve = new vExec("MACHINEADDRESS", "username", "password");

// Subscribe to OutputUpdated Event
ve.OutputUpdated += new EventHandler(ve_OutputUpdated);

private void ve_OutputUpdated(object sender, EventArgs e)
{
	// Update UI from different thread
	Invoke((Action)delegate { txtOutput.Text = ve.CmdOutput; });
}

private void button1_Click(object sender, EventArgs e)
{      
	// Run Method to begin command execution excepts command as string
	// Excample command: ipconfig
	
	ve.Run("ipconfig");
	
	//OR
	// Call the sub methods individually 
	
	/* 
	ve.RemoteCommand = "ipconfig";
        ve.ConnectWMI();
        ve.LaunchRemoteProcess();    
        */
}

####For WPF Applications

Replace Invoke with Dispatcher.Invoke

Dispatcher.Invoke((Action)delegate { txtOutput.Text = ve.CmdOutput; });

================== ####Properties

string RemoteComputer
string RemoteCommand
string UserName
string UserPass
string CmdOutput

####Public Methods

void Run(string command)	// Calls ConnectWMI() & LaunchRemoteProcess()

Methods for use when wanting to seperate connection and command execution calls

// Makes connection to remote machine 
void ConnectWMI()

// Creates command prompt process and runs the command provided as param
void LaunchRemoteProcess()

####Public Events

event EventHandler OutputUpdated	// Fires each time the output is updated; including connection logging
event EventHandler CmdFinished		// Fires after the command has completed and output has been collected

======================== NetConnect Utility Class

Uses Windows API to make connection to network resources

  • WNetUseConnection
  • WNetCancelConnection2
// Makes connection to UNC path specified and returns Error string
string ConnectNetResource(string remoteUNC, string username, string password)

// Disconnects mapped network resource at specified UNC path and returns Error string
string DisconnectNetResource(string remoteUNC)

vexec's People

Contributors

coolmacool avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.