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
265 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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display

831 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