?
Solved

Running Programs...

Posted on 2000-02-14
8
Medium Priority
?
219 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
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month15 days, 6 hours left to enroll

839 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