473,388 Members | 1,355 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes and contribute your articles to a community of 473,388 developers and data experts.

Execute a shell command from a program

sashi
1,754 Expert 1GB
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 6192

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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.