-5

Hey guys im trying to start a programm hidden with less priority but the command prompt still pop out.

Dim WShell
Set WShell = CreateObject("WScript.Shell")
WShell.Run "cmd /c Start /belowNormal " & "C:\Users\Desktop\sonso.exe -uri www.google.de",0
Set WShell = Nothing
user692942
  • 16,398
  • 7
  • 76
  • 175
meno
  • 23
  • 4

1 Answers1

0

You asked how to reduce exe priority from VBS without using CMD so here is an example. (I admit it is not all my own work, but performs as advertised for Notepad.exe)

Don't ask me exactly how it works and it took me ages to find as the vbs example is "missing" from the Microsoft setpriority-method-in-class-win32-process link I include.

enter image description here

Set Priority.vbs

' Set priority of process to Below Normal on Server 2008 & Vista+'
' From https://learn.microsoft.com/en-gb/windows/win32/cimwin32prov/setpriority-method-in-class-win32-process'
' Below Normal (16384) Indicates a process that has priority above IDLE_PRIORITY_CLASS (64),'
' but below NORMAL_PRIORITY_CLASS (32). NOTE:- combined namespace is \\. \Root\CIMV2
' Others ABOVE_NORMAL (32768) HIGH_PRIORITY (128) *REAL_TIME ( 256) *Note To set Realtime,
' the caller must have SeIncreaseBasePriorityPrivilege (SE_INC_BASE_PRIORITY_PRIVILEGE).
' Without this privilege, the highest the priority can be set to is High Priority.

' Use your RUN commands here and replace name = Notepad.exe below or replace Notepad.exe with arg[0]
Set objShell = WScript.CreateObject("WScript.Shell")
' With CMD but minimised so we can open it from taskbar
' objShell.Run "%comspec% /d /c start /min Notepad.exe fred.txt", 0, True
' Without CMD BUT NOT hidden, otherwise how are you going to edit anything or close Notepad.
objShell.Run "c:\windows\Notepad.exe fred.txt"

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\Root\CIMV2")
 
Set colProcesses = objWMIService.ExecQuery _
    ("Select * from Win32_Process Where Name = 'Notepad.exe'")
 
For Each objProcess in colProcesses
    objProcess.SetPriority(16384) 
Next

K J
  • 8,045
  • 3
  • 14
  • 36