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
261 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Name space syntax error 12 39
Host asp.net pages 5 25
SQL syntax in VB.net 5 27
Handle KeyDown for ToolStripDropDownButton, ToolStripMenuItem 3 17
Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

937 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

10 Experts available now in Live!

Get 1:1 Help Now