473,468 Members | 1,370 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Execute a shell command from a program

sashi
1,754 Recognized Expert Top Contributor
ShellExecute

Expand|Select|Wrap|Line Numbers
  1. 'Module code - modShellExecute
  2.  
  3. Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
  4.  
  5. 'vbHide = 0
  6. 'vbNormalFocus = 1
  7. 'vbMinimizedFocus = 2
  8. 'vbMaximizedFocus = 3
  9. 'vbNormalNoFocus = 4
  10. 'vbMinimizedNoFocus = 6
  11.  
  12. Public Enum vbWindowsState
  13.     Hide = 0
  14.     NormalFocus = 1
  15.     MinimizedFocus = 2
  16.     MaximizedFocus = 3
  17.     NormalNoFocus = 4
  18.     MinimizedNoFocus = 6
  19. End Enum
  20.  
  21. Public Function OpenApplication(ByVal strOperation As String, _
  22.                                 ByVal strApplicationName As String, _
  23.                                 ByVal strParameter As String, _
  24.                                 ByVal strApplicationDirectory As String, _
  25.                                 ByVal WindowsState As vbWindowsState) As Boolean
  26.  
  27. Dim nWindowsState As Integer
  28.  
  29.     Select Case WindowsState
  30.         Case 0
  31.             nWindowsState = vbHide
  32.         Case 1
  33.             nWindowsState = vbNormalFocus
  34.         Case 2
  35.             nWindowsState = vbMinimizedFocus
  36.         Case 3
  37.             nWindowsState = vbMaximizedFocus
  38.         Case 4
  39.             nWindowsState = vbNormalNoFocus
  40.         Case 6
  41.             nWindowsState = vbMinimizedNoFocus
  42.     End Select
  43.  
  44.     ShellExecute 0&, strOperation, strApplicationName, strParameter, strApplicationDirectory, WindowsState
  45. End Function
  46.  
  47. 'Form code - frmShellExecute
  48.  
  49. Private Sub cmdShellExecute_Click()
  50.     modShellExecute.OpenApplication vbNullString, "The Application", vbNullString, vbNullString, MaximizedFocus
  51. End Sub
  52.  
Dec 4 '06 #1
0 6197

Sign in to post your reply or Sign up for a free account.

Similar topics

13
by: BlackHawke | last post by:
Our program, game program Andromeda Online (www.andromedaonline.net) uses two programs- one to play the game, another to patch the game as updates come out. Players actually launch the updater...
1
by: Valentine Kouznetsov | last post by:
Hi, simple question, how to execute command in current shell, not in subshell? Example. I have environment variable A=aaa and need to invoke shell (sh) script which will do something with A. If...
11
by: penguinman | last post by:
I type ./a.out and the shell just sits there. It doesnt hang it just sits there looking pretty. I run the program with the ddd option and executed it from ddd...execution window comes up and...
8
by: Siemel Naran | last post by:
Hi. I'm writing a command shell that reads commands from standard input. At this point I have the command in a std::string. Now I want to execute this command in the shell. From the Borland...
4
by: alberto | last post by:
How can I execute a command of the operating system like "cls" from a C# code? Thank you
5
by: Jeffrey Grantz | last post by:
I have the following routine that I thought was streight forward (I should know better) Private Sub DOS_Command() Dim lRetVal As Long lRetVal = Shell("erase ""Z:\IDW2\XML Report...
9
by: sohan | last post by:
Hi, I want to know how to connect and execute a db2 query from inside a UNIX shell script. Details: We have a unix shell script. We need to execute multiple db2 sql queries from this shell...
3
by: =?Utf-8?B?S3VlaXNoaW9uZyBUdQ==?= | last post by:
I have a .NET VC++ program, I want to execute some dos command from the program, e.g. copy some file, and etc. How do I do that?
2
by: revenant81 | last post by:
I'm writing a program which has to execute a command, get its output and show it on a treeview. This command runs for a very long time. I want to end the execution of the command when the user...
1
by: raocheng | last post by:
Please see the following code. Suppose I have many shell commands to be executed. And I don't want to fork a sub shell for each command(eg: status,output = commands.getstatusoutput(cmd)) because...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.