Solved

vb.net can I run program from a v by vb.net installed on a client by using command line?

Posted on 2010-08-12
6
258 Views
Last Modified: 2013-11-26
I want to run .exe , vbscript, shel programs from my folder on my vb.net app...and I need to run a vbscript that will have access to the clinet command line...is this a problem?  I dont believe so...but before I start this big project i need to be sure...thanks
0
Comment
Question by:GlobaLevel
  • 3
  • 3
6 Comments
 
LVL 3

Expert Comment

by:bkokx
ID: 33427059
You can run anything from a VB.Net app when you have sufficient credentials on the system. Could you be a bit more precise. The VB.NET code below writes a vbscript and then executes it from the same location.
Module Module1



    Sub Main()



        Dim sw As System.IO.StreamWriter

        sw = System.IO.File.CreateText(".\myscript.vbs")

        sw.WriteLine("Dim Shell")

        sw.WriteLine("Set Shell = WScript.CreateObject(""WScript.Shell"")")

        sw.WriteLine("Shell.Run(""c:\windows\system32\calc.exe"")")

        sw.Close()

        Shell("cscript .\myscript.vbs")

    End Sub



End Module

Open in new window

0
 
LVL 10

Author Comment

by:GlobaLevel
ID: 33429785
1) the vb.net app sits locally will be launched from a remote app via .net.sockets
2) once the vb.net launches it will run to a remote db via system.data sql connection and pull the latest data stored in a string variable
0
 
LVL 10

Author Comment

by:GlobaLevel
ID: 33429983
1) the vb.net app sits locally will be launched from a remote app via .net.sockets
2) once the vb.net launches it will run to a remote db via system.data sql connection and pull the latest data stored in a string variable over a secure connection (using a .pfx in vb.net?)?
3) comes back to the vb.net app and launch a vbscript that is stored in a folder inside the vb.net app
4) the string from the remote db will be passed into the vbscript
5) the vbscript will run this string against a .exe (the .exe is stored in a folder in the vb.net-AND THE FOLDER MUST BE SECURED_SO NO USER ACCESS ONLY ADMIN) via a command line
6) the the vbscript then will take the values from the command line and store in a .txt file in a log folder from inseide
the vb.net
7) the vb.nett will send this same data back to the remote db...


if you have code for the above..wow that would be great..i know its general...but the specifics can be added later..


0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 3

Expert Comment

by:bkokx
ID: 33433315
Hi GlobaLevel,

Sounds like a very complex way of solving things.... Why have all these steps instead of having a single application listening on a port that accepts commands from a remote system and executes it?
0
 
LVL 10

Author Comment

by:GlobaLevel
ID: 33435158
bkokx,

Great idea..I thought that was what I was doing..if you have any samples..great!
0
 
LVL 3

Accepted Solution

by:
bkokx earned 500 total points
ID: 33439453
Hi GLobaLevel,

When I look at your original requirements I have the following design remarks:
1. Your client application should be running already on the client either as a normal application or (prefered) as a windows service. This of course requires pre-installation. Now of course the question is how will the application be triggered, does it regularly poll the server or does the server go on the network to search and connect to the clients?
2. There are many ways to get the string mainly depending on how you implement the application; one would be that the server just returns the string at once so you do not need a database connection or you could determine that the sql is the server application so you do not need a server side application. In the later case ensure you also have a unique number so the client can track if the command has already been executed.
3/4/5/6. I would run all of this from inside the service, so no additional vbscripts unless of course there are addition design constraints that I do not known. Running it as a service also simplifies protection.
7. Again depending on your design choices you could send a response string to the server application or work directly with the database.

Of course this is a more complex app to write but for many of its elements you will find good examples on the internet, some that will get you on your way are:

http://www.codeguru.com/vb/gen/vb_system/services/article.php/c4825
http://www.codeguru.com/columns/dotnet/article.php/c6027
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now