Solved

Installing a program using Shell in VB

Posted on 2003-11-26
7
310 Views
Last Modified: 2011-09-20
I have an anti-virus program and set up files are in folder called c:\anti-virus

I can install that program typing c:\anti-virus\setup.exe

I want to call this program from my vb application. This is what i am doing in my program

dim strCommand as string
strCommand =
"c|windows\system32\cmd.exe c:\anti-virus\setup.exe"
shell strCommand, vbHide

I can run this and install the program, but i keep getting 'unsupported operation..." message. I am using Windows 2000. Using Win XP i don't have any problem, it installs smooth.

Can anyone help?






0
Comment
Question by:siva_manikoth
7 Comments
 
LVL 10

Expert Comment

by:D_M_D
ID: 9826090
Try removing the cmd part...

Shell "C:\anti-virus\setup.exe", vbHide


--------
D_M_D
0
 

Expert Comment

by:jcran
ID: 9828608


Private Sub ExecAndWait(strAppName)
     Dim hProcessID&, hProcess&
     Dim lngExitCode

     hProcessID = Shell(strAppName, vbNormalFocus)
     hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, False, hProcessID)
End Sub

see: http://beta.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/VB_Controls/Q_20711948.html
0
 
LVL 9

Expert Comment

by:bhagyesht
ID: 9829552
pass a parameter to the cmd.exe /c modified as below

otherwise ignore cmd.exe totally


option 1

dim strCommand as string
strCommand =
"c|windows\system32\cmd.exe /c c:\anti-virus\setup.exe"
shell strCommand, vbHide


option 2
shell "c:\anti-virus\setup.exe" , vbHide
0
 

Author Comment

by:siva_manikoth
ID: 9842142
I have figured out that this error occures when used with CreateProcessWithLogonW () Windows API function. Let me elaborate.

I have a VB program, let us say A.exe, which is deployed in a Windows 2000 Domain Server. When a user (Win2K client) logs in, A.EXE is executed. A.EXE calls another program, let us say, B.EXE using CreateProcessWithLogonW() Win API call. I am using CreateProcessWithLogonW() to passon admin privileage to B.EXE, since log-in user is not an administrator. B.EXE calls the anti-virus set-up program.

When the anti-virus software is installed I keep getting "An unsupported operation was attempted" message, though after keep pressing "OK" button, I can install the software.

If B.EXE is called directly, instead of calling from A.EXE, I can install the software without any  problem. So the problem is with CreateProcessWithLogonW(). But I can not do away with CreateProcessWithLogonW() since log-in user does not have the rights to install the anti-virus program
0
 

Accepted Solution

by:
ee_ai_construct earned 0 total points
ID: 10982411
PAQed, with points refunded (125)

ee_ai_construct - (re-order part number #xm34)
Community Support Moderator
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

This article will show, step by step, how to integrate R code into a R Sweave document
A short article about a problem I had getting the GPS LocationListener working.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …

809 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