?
Solved

Running Programs...

Posted on 2000-02-14
8
Medium Priority
?
214 Views
Last Modified: 2010-05-02
I have a home computer that I allow every one to use. I have a program that is started with the autoexect.bat file when the computer is starting up. How ever I would not like this program to run when I log in to the machine (using standard windows login) win95. I decided that I would just put a small program in the startup folder for my login that would terminate this program but I can't seem to do it??? When I press ctr-alt-del the program does not even show up... I guess my experences is lacking in this area. Any help would be nice. (Please tone it down though) Thanks!
0
Comment
Question by:testing38
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 3

Expert Comment

by:Michelt
ID: 2520456
If You Can't find it under Programs, try active Processes.  

Okay Try the following.

This will give you list of all the Active processes.

Create a form with a Command button and a Listbox

Add a module and enter the following code:

Option Explicit
Public Const TH32CS_SNAPPROCESS As Long = 2&
Public Const MAX_PATH As Integer = 260
Public Type PROCESSENTRY32
dwSize As Long
cntUsage As Long
th32ProcessID As Long
th32DefaultHeapID As Long
th32ModuleID As Long
cntThreads As Long
th32ParentProcessID As Long
pcPriClassBase As Long
dwFlags As Long
szExeFile As String * MAX_PATH
End Type
Public Declare Function CreateToolhelpSnapshot Lib "Kernel32" _
Alias "CreateToolhelp32Snapshot" _
(ByVal lFlags As Long, ByVal lProcessID As Long) As Long

Public Declare Function ProcessFirst Lib "Kernel32" _
Alias "Process32First" _
(ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long

Public Declare Function ProcessNext Lib "Kernel32" _
Alias "Process32Next" _
(ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long

Public Declare Sub CloseHandle Lib "Kernel32" _
(ByVal hPass As Long)


Then in the main form enter this code under the command button

Dim hSnapShot As Long
Dim uProcess As PROCESSENTRY32
Dim r As Long
hSnapShot = CreateToolhelpSnapshot(TH32CS_SNAPPROCESS, 0&)
If hSnapShot = 0 Then
Exit Sub
End If
uProcess.dwSize = Len(uProcess)
r = ProcessFirst(hSnapShot, uProcess)
Do While r
List1.AddItem uProcess.szExeFile
r = ProcessNext(hSnapShot, uProcess)
Loop
Call CloseHandle(hSnapShot)
0
 
LVL 32

Expert Comment

by:Erick37
ID: 2520503
testing
What is the program you want to terminate?
Most Autoexec.bat exe's are device drivers and are resident before Windows loads.
0
 
LVL 7

Expert Comment

by:kamall
ID: 2521066
I would suggest the opposit approach. That is, depending on the login name, you either run the program or not. This can be done by removing the program from the autoexec.bat, making a small VB program that will detect the login name, and then decide to whether run (shell) the program or not.
Regards.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 12

Expert Comment

by:roverm
ID: 2521616
Kamall is correct, you can use something like this:

Declare Function WNetGetUser& Lib "Mpr" Alias "WNetGetUserA" (lpName As Any, ByVal lpUserName$, lpnLength&)

Private Sub StartUp()
Dim cbusername As Long, username As String

username = Space(256)
cbusername = Len(username)
If WNetGetUser(ByVal 0&, username, cbusername) = 0 Then
    If Left(username, (Len(RTrim(username)) - 3)) <> "MyLoginName" Then
        Shell "appname"
    End If
End If

End Sub

I've used an API to retreive the name of the user logged in, then checked it against your own log in name. If it is not the same then the SHELL statement fires the application.

Good Luck !

RoverM

0
 

Author Comment

by:testing38
ID: 2524135
I'm afraid that the 'starting the program after login' wont work. The program needs to be started in the autoexect.bat file before windows. I guess then windows could not stop it... But maybe. Any one else have any ideas? Also the program does not show up under the Processes. It does, however show up when I type mem /c /p at the dos command prompt, if that helps any.
0
 
LVL 7

Expert Comment

by:kamall
ID: 2525416
Is it a DOS program?
If it is, it will show as 'winoldapp' (or something like that) in the processes.
I wonder why it wont work after windows loads. What program is that?
0
 
LVL 2

Accepted Solution

by:
danlevans earned 2400 total points
ID: 2536280
testing38

Have your dos program to run only when a file does not exist. Then when you logon have your startup create this file--then wait long enough for your dos program to sense it and quit, then delete the file.

Rinky dink but it works. The only way I know for a dos program started before windows to communicate with a windows program.

Have Fun

Dan
0
 

Author Comment

by:testing38
ID: 2578456
danlevans: I think I can pull this off! This is a good idea. Not what I had in mind but it will work. Thanks for the help!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses
Course of the Month10 days, 13 hours left to enroll

765 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