1.

Solve : Create Driver?

Answer»

Hello,

I would like to know hows to create a driver, all that this driver would do is launch an executable and male sure that its process is not terminated. This is kind of a protection for a security program.

Thanks

Al968I don't think a driver is the issue. You may want to google about for info on batch files, etc.Thank you for the responce,

could you explain what you mean because I don't see the relation with batch files??

Thanks

Al968
How about I just move this to the DOS forum as this has nothing to do with drivers?Your question is a bit ambiguous, but I'm guessing you need a script to monitor the execution status of a program and restart it if necessary.

A VBScript can help:

Code: [Select]strComputer = "."
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run "[highlight]c:\windows\system32\notepad.exe[/highlight]"

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set objEventSource = objWMIService.ExecNotificationQuery _
("SELECT * FROM __InstanceOperationEvent WITHIN 2 WHERE TargetInstance ISA 'Win32_Process'")

Do While True
Set objEventObject = objEventSource.NextEvent()
If objEventObject.TargetInstance.Name = "[highlight]notepad.exe[/highlight]" Then
Select Case objEventObject.Path_.Class
Case "__InstanceDeletionEvent"
WshShell.Run "[highlight]c:\windows\system32\notepad.exe[/highlight]"
End Select
End If
Loop

The example uses notepad.exe, but you can use any executable. Save script with a vbs extension and run from the command prompt as wscript scriptname.vbs. Path information may be needed depending on your environment.

Good luck. 8-)

PS. A batch solution would need a loop, which would suck up CPU cycles. A VBScript can actually wait for events to happen. Are you sure that this works ??

I get an error message':

script: c:\script.vbs
line: 4
char: 1
error: 0x80041021
code: 8004121
source: (null)


I am running XP Home.

Thanks

Al968Works fine on my XP Home machine. The only variable in line 4 is strComputer, which is set in line 1 of the script. Scripts of this type are mostly boilerplate code....did you cut and paste the script in it's entirety?

:-?

BTW: setting strComputer to a dot is shorthand for the local computer. You might also want to adjust the WITHIN 2 clause. The 2 REPRESENTS seconds.Yes I did COPY the code exactly as you said :-?
I am sorry but I don't know VBScript. Can you clarify what I qhould do.

Thanks

Al968

Not knowing what you are doing makes it difficult to debug. Save the script (cut and paste into notepad is fine).

To run the script, type: wscript scriptname.vbs from a command prompt. If you are not logged on to the same directory as to where you saved the script you will need to provide a path pointer. (example: wscript drive:\path\scriptname.vbs)

If you still have problems, please post a screen print of the command prompt output so we can see exactly what's going on.Still getting the problem, I saved the vbs script in c:\document and settings\my username, I ATTACHED the sreen shot.

Thanks

Al968Well, I'm at a loss for words You're obviously logged into the correct directory otherwise the error would be different.

Just for kicks, post back your version of the script. This is getting very interesting. 8-)Its the EXACT same one:

Set WshShell = CreateObject("WScript.Shell")
WshShell.Run "c:\windows\system32\notepad.exe"

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set objEventSource = objWMIService.ExecNotificationQuery _
("SELECT * FROM __InstanceOperationEvent WITHIN 2 WHERE TargetInstance ISA 'Win32_Process'")

Do While True
Set objEventObject = objEventSource.NextEvent()
If objEventObject.TargetInstance.Name = "notepad.exe" Then
Select Case objEventObject.Path_.Class
Case "__InstanceDeletionEvent"
WshShell.Run "c:\windows\system32\notepad.exe"
End Select
End If
Loop


Thanks

Al968Quote

Its the exact same one:
*sigh*

Not quite. It seems line 1 of the original script has gone missing. See reply #4.

[highlight]strComputer = "."[/highlight] points to the local machine.

Good luck. 8-)
Sorry, well it WORS now but its using too much processor

Thanks Any Way

Al968


Discussion

No Comment Found