Const Above_Normal = 32768
Dim objSWbemObjectEx
Dim lngProcessID
Dim colProcesses
Dim bUser
Dim strNameOfUser
Dim UserName
UserName = CreateObject("WScript.Network").UserName
With WScript.CreateObject("WbemScripting.SWbemLocator").ConnectServer(".", "root\cimv2")
Set colProcesses = .ExecQuery("SELECT * FROM Win32_Process WHERE Name = '1cv8.exe'")
Set objSWbemObjectEx = .Get("Win32_ProcessStartup")
bUser = False
For Each objProcess in colProcesses
Return = objProcess.GetOwner(strNameOfUser)
If Return = 0 Then
If strNameOfUser = UserName Then
bUser = True
End If
End If
Next
If Not bUser Then
objSWbemObjectEx.PriorityClass = Above_Normal
' Create method of the Win32_Process class (Windows) (
http://msdn.microsoft.com/en-us/libr...(v=vs.85).aspx)
If .Get("Win32_Process").Create( _
"""C:\Program Files (x86)\1cv82\8.2.16.352\bin\1cv8.exe""", _
"C:\Program Files (x86)\1cv82\8.2.16.352\bin", _
objSWbemObjectEx, _
lngProcessID _
) <> 0 Then
WScript.Echo "Can't start process [""%Program Files (x86)\1cv82\8.2.16.352\bin""."
End If
Set objSWbemObjectEx = Nothing
End If
End With
WScript.Quit 0