Solved

Running Programs...

Posted on 2000-02-14
8
206 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
 
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

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 600 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

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…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

760 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

23 Experts available now in Live!

Get 1:1 Help Now