Solved

Installing a program using Shell in VB

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

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

Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
This is about my first experience with programming Arduino.
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 …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

911 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

17 Experts available now in Live!

Get 1:1 Help Now