Link to home
Start Free TrialLog in
Avatar of Indarnav
Indarnav

asked on

special run

i have two exes. a.exe and b.exe.

in normal way if i run a.exe first and then try to run b.exe, it will allow second file to run. it will terminate b.exe process.

now i want to know is there any code that i can add to a.exe and/or  b.exe, so that whenever b.exe runs, a.exe can check its authenticity and allow it and if b.exe failed to show its authencity, a.exe will terminate it again as it is doing in normal run.

both exe's are written in vbs.
Avatar of RobSampson
RobSampson
Flag of Australia image

Hi, how do you know the file is authentic? What do we need to check to know that?
Avatar of Indarnav
Indarnav

ASKER

i do not know, but any unique property of file, which can not be easily created and can be read by file b.exe.
see there are so many properties of file like size, version,  but u can better think which property is very unique and can not be captured by unauthorised person.
robsampson... u got any idea on how to do it? waiting for your reply.
Hi, sorry for my delay. The first think I need to work out is exactly how you want these files to work.

You have a.exe. What happens if you run that on it's own? Does it do anything?  And what happens if you run b.exe on it's own?

Do you want b.exe to run only if a.exe has been run recently, say in the last two minutes?

Regards,

Rob.
both exe are written in vbs. both are written by me. basic intention is if b.exe is running, then it allow only my a.exe to run no any other.
no any other means, no other exe with a.exe name...
So:
if b.exe is running, then it allow only a.exe to run
if a.exe tries to run, check that b.exe is running first, and is the correct b.exe file

would that be right?

Rob.
every time suppose b.exe is running

now i tried to run my a.exe, made by me, b.exe will allow it.
now suppose i rename notepad.exe to a.exe and tried to run, b.exe will not allow it to run.

a.exe can be run from any position, if it is made by me, it should run.
What program are you using to compile your VBScripts into EXEs?

Try adding this code to b.exe, where you need to change the objFile.DateCreated value and objFile.Size value to match the exact values on your a.exe when it is finished.

Regards,

Rob.
Set objFSO = CreateObject("Scripting.FileSystemObject")
Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colMonitoredEvents = objWMIService.ExecNotificationQuery("SELECT * FROM __InstanceCreationEvent " & _
                                    "WITHIN 1 WHERE Targetinstance ISA 'Win32_Process' " & _
                                    "and TargetInstance.Name='a.exe'")
' set up an endless loop to watch for a.exe
Do
	Set objLatestEvent = colMonitoredEvents.NextEvent
	Notifier(objLatestEvent.TargetInstance)
	WScript.Sleep 1000
Loop
 
Sub Notifier(objItem)
	Set objFile = objFSO.GetFile(objItem.ExecutablePath)
	MsgBox objFile.DateCreated & VbCrLf & objFile.Size
	If objFile.DateCreated <> "30/07/2009 12:50:15 PM" Or objFile.Size <> 98304 Then
		objItem.Terminate
		MsgBox objItem.ExecutablePath & " has been terminated."
	End If
End Sub

Open in new window

should i write size  or size on disk? also size should be in KB or bytes?
The size will need to be in bytes, and use just Size.

Rob.
i tested, but it is terminating a.exe even when all values matches. ..
i retested, and changed date style, it is working..let me check it again. earlier i mentioned 03/12/2009 , when date of file was 3/12/2009, in this case code terminated file.

do u like to amend something.
in my system, date style is mm/dd/yyyy, then will code gives different result if date style is different say dd/mm/yyyy, ?
pls guide what changes would i do in code so that i can check thee exes simultaneously . present code is checking only a.exe.
ASKER CERTIFIED SOLUTION
Avatar of RobSampson
RobSampson
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial