Solved

Installing a program using Shell in VB

Posted on 2003-11-26
7
299 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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 …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

707 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

18 Experts available now in Live!

Get 1:1 Help Now