2016-03-20 13 views
0
MsgBox ("Do you want to start the autoclicker?", vbOkOnly, "Autoclicker") 
CreateObject("WScript.Shell").Run("""C:\Users\Henry\Desktop\Fun.vbs""") 
MsgBox ("Do you want to stop the autoclicker?", vbOkOnly, "Autoclicker") 
+1

Daha iyi kod formatını:

Dolayısıyla, sadece, bir deneyin. Kodun amaçlanan kullanımının daha uzun bir açıklaması yararlı olacaktır. –

cevap

0
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2") 

Set colItems = objWMIService.ExecQuery("Select * From Win32_Process") 

For Each objItem in colItems 
    'msgbox objItem.ProcessID & " " & objItem.CommandLine 
    If objItem.name = "Calculator.exe" then objItem.terminate 
Next 

Bu calculator.exe öldürür. Wscript.exe olarak değiştirin. Sadece fun.vbs dosyasını öldürmek istiyorsanız komut satırını kontrol etmek isteyebilirsiniz.

+0

Teşekkür ederim bu gerçekten yardımcı olur – Jontzjr

0

Aşağıdaki yordam, komut satırları belirtilen bir dizeyi içeren tüm işlemleri öldürür. Rutinin altındaki 3 satır test etmek içindir. Bir ileti kutusu göstererek rutini duraklatırız ve mesaj kutusunu kapattığınızda, komut dosyası örneğini öldürürüz, böylece ikinci mesaj kutusu görünmez. Bunu kullandığınızda, bu kullanırken dikkatli olmak ve emin kesinlikle olumlu sadece süreçlerini maç yapmak mümkün olduğunca komut satırının kadar belirtmek istiyorum

KillProcesses "Fun.vbs" 

ile son 3 satırları değiştirmek istiyor ben son vermek istiyorum. Görev Yöneticisi'ni değiştirebilir ve her çalışan işlem için komut satırını gösterecek bir sütun ekleyebilirsiniz. Aşağıdaki rutinde, komut satırındaki arama büyük/küçük harf duyarlıdır.

Option Explicit 

Sub KillProcesses(strPartOfCommandLine) 
    Dim colProcesses 
    Dim objProcess 
    Dim lReturn 


    ' Get list of running processes using WMI 
    Set colProcesses = GetObject("winmgmts:\\.\root\cimv2").ExecQuery("Select * From Win32_Process") 

    For Each objProcess in colProcesses 
     If (Instr(1, objProcess.Commandline, strPartOfCommandLine, vbTextCompare) <> 0) Then 
      lReturn = objProcess.Terminate(0) 
     End If 
    Next 
End Sub 

Msgbox "Before being killed" 
KillProcesses "KillProcesses.vbs" 
Msgbox "After being killed" 
0

Vbscript'i öldürmek ve sonucu bir dosyaya kaydetmek istediğinizi soran bir komut dosyası hazırladım.

Option Explicit 
Dim Titre,Copyright,fso,ws,NomFichierLog,temp,PathNomFichierLog,OutPut,Count,strComputer 
Copyright = "[© Hackoo © 2014 ]" 
Titre = " Process "& DblQuote("Wscript.exe") &" running " 
Set fso = CreateObject("Scripting.FileSystemObject") 
Set ws = CreateObject("Wscript.Shell") 
NomFichierLog="Process_WScript.txt" 
temp = ws.ExpandEnvironmentStrings("%temp%") 
PathNomFichierLog = temp & "\" & NomFichierLog 
Set OutPut = fso.CreateTextFile(temp & "\" & NomFichierLog,1) 
Count = 0 
strComputer = "." 
Call Find("wscript.exe") 
Call Explorer(PathNomFichierLog) 
'*************************************************************************************************** 
Function Explorer(File) 
    Dim ws 
    Set ws = CreateObject("wscript.shell") 
    ws.run "Explorer "& File & "\",1,True 
end Function 
'*************************************************************************************************** 
Sub Find(MyProcess) 
    Dim colItems,objItem,Processus,Question 
    Set colItems = GetObject("winmgmts:").ExecQuery("Select * from Win32_Process " _ 
    & "Where Name like '%"& MyProcess &"%' AND NOT commandline like '%" & wsh.scriptname & "%'",,48) 
    For Each objItem in colItems 
     Count= Count + 1 
     Processus = Mid(objItem.CommandLine,InStr(objItem.CommandLine,""" """) + 2) 'Extraction of the commandline script path 
     Processus = Replace(Processus,chr(34),"") 
     Question = MsgBox ("Did you want to stop this script : "& DblQuote(Processus) &" ?" ,VBYesNO+VbQuestion,Titre+Copyright) 
     If Question = VbYes then 
      objItem.Terminate(0)'Kill this process 
      OutPut.WriteLine DblQuote(Processus) 
     else 
      Count= Count - 1 'decrement the counter -1 
     End if 
    Next 
OutPut.WriteLine String(100,"*") 
OutPut.WriteLine count & Titre & " were stopped !" 
End Sub 
'********************************************************************************************** 
Function DblQuote(Str) 
    DblQuote = Chr(34) & Str & Chr(34) 
End Function 
'********************************************************************************************** 
İlgili konular