Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to make a button click execute a simple exe file? 1

Status
Not open for further replies.

GezaL

MIS
Mar 19, 2003
6
US
Hello!
I am trying to create a MOTD popup window with an "accept" and "Deny" buttons, where the click on the "Deny" button would execute a "\\server\share\logoff.exe" command.
or something similar.

How do you do this?
How do you declare an executable file including the full path?

Geza
 
Hi,

If you simply need to call an outside executable and get back a return on if it succeeded or not i suggest you use the old VB6 way of calling into the command object.

lblnPrinted = Microsoft.VisualBasic.Shell("c:\windows\calc.exe", AppWinStyle.Hide, True)

Hope this Helps
 
Hi!
I inserted your line with a modified path to the exe file, but now I get blue underline error on "lblnPrinted" indicating that it is not declared. How do I declare this?
Geza

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
lblnPrinted = Microsoft.VisualBasic.Shell("c:\winnt\system32\calc.exe", AppWinStyle.Hide, True)

 
Drop a label on your form named "lblnPrinted"

Chip H.
 
Hi Chip,
It was complaining about the an integer value can not be assigned to a label, but I modified it and now it works great!
(I don't really need a feedback to a label right now)
You put me on the right track. Thanks!!!
Geza


Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim x As Integer
Close()
x = Microsoft.VisualBasic.Shell("c:\winnt\system32\calc.exe", AppWinStyle.Hide, True)
End Sub
 
Hi Chip,
I thought that I am done, but I had to realize soon, that I am not.

I.E. the final executable runs fine on my PC (W2K)(that I have VB Studio.NET installed on, but when I try to execute it on an NT4 workstation, first it couldn't find a file "mscoree.dll" then when I copied it in the same folder where the exe file is, then I got an error message:
Title bar: .NET Framework Initialization Error
Message: Please, set registry key HKLM\Software\Microsoft\NETFramework\InstallRoot to print to the .NET Framework install location. OK.

So, now the $64000 question is: How can I make the final executable file to run independently or maybe with couple dll files?
Geza
 
Geza,

Forgot to include what lblnPrinted was.
dim lblnPrinted as boolean

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top