Datamation content and product recommendations are
editorially independent. We may make money when you click on links
to our partners.
Learn More
Author:Darron Nesbitt
Platform: Windows NT, Windows 2000
Type: VBScript
DESCRIPTION: These two scripts utilize WMI to connect to and run or kill an application on a remote PC. The scripts will run on Windows 2000 or Windows NT.
Execute Remote App script:
This script when executed prompts for the following:
Remote computer’s name
Path to application that will be executed on the remote computer
Path to directory Application resides in
Onces succesfully started a process id will be returned along with the process owner.
Kill Remote App script:
This script when executed prompts for the following:
Remote computer’s name
Process ID of the application to kill
Download the script.
Scroll down to view the script.
SCRIPT:
'************************************************************************
'* This script is for executing an application on a remote
'* computer running Win2K or WinNT w/WMI installed.
'*
'* Author: Darron Nesbitt
'* Date: 7/10/2001
'*
'************************************************************************
Dim strComputerName ' The Computer Name to be queried via WMI
Dim strWinMgt ' The WMI management String
On Error Resume Next
'get computer's name or ip address
strComputerName = ucase(InputBox("Enter the remote computers name or IP","Computer Name/IP"))
AppPath = ucase(InputBox("Enter path to application:" & VBCRLF & VBCRLF & "Example:C:WINNTSYSTEM32Calc.exe","Application Path"))
WorkingDirectory = ucase(InputBox("Enter path to application directory" & VBCRLF & VBCRLF & "Example: C:WINNTSYSTEM32","Application Working Directory"))
strWinMgt = "winmgmts://" & strComputerName & ""
'
' Get Computer/User Info
'
Set CompSysSet = GetObject(strWinMgt).ExecQuery("select * from Win32_ComputerSystem")
for each CompSys in CompSysSet
strDescription = CompSys.Description
strModel= CompSys.Model
strName= CompSys.Name
strManufacturer = CompSys.Manufacturer
strUserName = CompSys.UserName
next
CompInfo = "Computer Information" & VBCrLf & VBCrLf
CompInfo = CompInfo & "Computer Name: " & strName & VBTab & "User: " & strUserName & VBCrLf
'connect to processes
Set Process = GetObject(strWinMgt).Get("Win32_Process")
'start app
RetVal = Process.Create (AppPath,WorkingDirectory,null,PID)
'if 0 not returned error
if RetVal 0 then
MsgBox "Error: " & Err.Description & ":" & Err.Number
else
'build ProcessInfo string
Set Processes = GetObject(strWinMgt).ExecQuery("select * from Win32_Process where ProcessID = " & PID)
for each Process in Processes
RetVal = Process.GetOwner(strUser,strDomain)
ProcessInfo = "Name: " & Process.Caption & VBTAB & "ProcessID: " & PID & VBCRLF
ProcessInfo = ProcessInfo & "Process Owner: " & ucase(strDomain) & "" & ucase(strUser) & VBCRLF
next
'display info about computer and process
RetVal = MsgBox (CompInfo & VBCRLF & VBCRLF & "Application started." & VBCRLF & VBCRLF & _
ProcessInfo,VBOKOnly,strComputerName & " - Start Application")
end if
msgbox "Done!!"
'************************************************************************
'* This script is for Killing an application on a remote
'* computer running Win2K or WinNT w/WMI installed. To use you need
'* the process id of the application.
'*
'* Author: Darron Nesbitt
'* Date: 7/10/2001
'*
'************************************************************************
Dim strComputerName ' The Computer Name to be queried via WMI
Dim strWinMgt ' The WMI management String
On Error Resume Next
'get computer's name or ip address
strComputerName = ucase(InputBox("Enter the remote computers name or IP","Computer Name/IP"))
PID = InputBox("Enter the applications Process ID","Process ID to Kill")
strWinMgt = "winmgmts://" & strComputerName & ""
'
' Get Computer/User Info
'
Set CompSysSet = GetObject(strWinMgt).ExecQuery("select * from Win32_ComputerSystem")
for each CompSys in CompSysSet
strDescription = CompSys.Description
strModel= CompSys.Model
strName= CompSys.Name
strManufacturer = CompSys.Manufacturer
strUserName = CompSys.UserName
next
CompInfo = "Computer Information" & VBCrLf & VBCrLf
CompInfo = CompInfo & "Computer Name: " & strName & VBTab & "User: " & strUserName & VBCrLf
'build ProcessInfo string
Set Processes = GetObject(strWinMgt).ExecQuery("select * from Win32_Process where ProcessID = " & PID)
for each Process in Processes
RetVal = Process.GetOwner(strUser,strDomain)
ProcessInfo = "Name: " & Process.Caption & VBTAB & "ProcessID: " & PID & VBCRLF
ProcessInfo = ProcessInfo & "Process Owner: " & ucase(strDomain) & "" & ucase(strUser) & VBCRLF
'display info about computer and process
RetVal = MsgBox (CompInfo & VBCRLF & VBCRLF & "Application to Kill:" & VBCRLF & VBCRLF & _
ProcessInfo & VBCRLF & VBCRLF & "Do you want to kill this process?",VBYesNo,strComputerName & " - Kill Application")
if RetVal = 6 then
RetVal = Process.Terminate(0)
end if
next
'if 0 not returned error
if RetVal 0 then
MsgBox "Error: " & Err.Description & ":" & Err.Number
end if
msgbox "Done!!"
Disclaimer: We hope that the information in these pages is valuable to you. Your use of the information contained in these pages, however, is at your sole risk. All information on these pages is provided “as -is”, without any warranty, whether express or implied, of its accuracy, completeness, fitness for a particular purpose, title or non-infringement, and none of the third-party products or information mentioned in the work are authored, recommended, supported or guaranteed by me. I shall not be liable for any damages you may sustain by using this information, whether direct, indirect, special, incidental or consequential, even if it has been advised of the possibility of such damages.
-
Ethics and Artificial Intelligence: Driving Greater Equality
FEATURE | By James Maguire,
December 16, 2020
-
AI vs. Machine Learning vs. Deep Learning
FEATURE | By Cynthia Harvey,
December 11, 2020
-
Huawei’s AI Update: Things Are Moving Faster Than We Think
FEATURE | By Rob Enderle,
December 04, 2020
-
Keeping Machine Learning Algorithms Honest in the ‘Ethics-First’ Era
ARTIFICIAL INTELLIGENCE | By Guest Author,
November 18, 2020
-
Key Trends in Chatbots and RPA
FEATURE | By Guest Author,
November 10, 2020
-
Top 10 AIOps Companies
FEATURE | By Samuel Greengard,
November 05, 2020
-
What is Text Analysis?
ARTIFICIAL INTELLIGENCE | By Guest Author,
November 02, 2020
-
How Intel’s Work With Autonomous Cars Could Redefine General Purpose AI
ARTIFICIAL INTELLIGENCE | By Rob Enderle,
October 29, 2020
-
Dell Technologies World: Weaving Together Human And Machine Interaction For AI And Robotics
ARTIFICIAL INTELLIGENCE | By Rob Enderle,
October 23, 2020
-
The Super Moderator, or How IBM Project Debater Could Save Social Media
FEATURE | By Rob Enderle,
October 16, 2020
-
Top 10 Chatbot Platforms
FEATURE | By Cynthia Harvey,
October 07, 2020
-
Finding a Career Path in AI
ARTIFICIAL INTELLIGENCE | By Guest Author,
October 05, 2020
-
CIOs Discuss the Promise of AI and Data Science
FEATURE | By Guest Author,
September 25, 2020
-
Microsoft Is Building An AI Product That Could Predict The Future
FEATURE | By Rob Enderle,
September 25, 2020
-
Top 10 Machine Learning Companies 2021
FEATURE | By Cynthia Harvey,
September 22, 2020
-
NVIDIA and ARM: Massively Changing The AI Landscape
ARTIFICIAL INTELLIGENCE | By Rob Enderle,
September 18, 2020
-
Continuous Intelligence: Expert Discussion [Video and Podcast]
ARTIFICIAL INTELLIGENCE | By James Maguire,
September 14, 2020
-
Artificial Intelligence: Governance and Ethics [Video]
ARTIFICIAL INTELLIGENCE | By James Maguire,
September 13, 2020
-
IBM Watson At The US Open: Showcasing The Power Of A Mature Enterprise-Class AI
FEATURE | By Rob Enderle,
September 11, 2020
-
Artificial Intelligence: Perception vs. Reality
FEATURE | By James Maguire,
September 09, 2020
SEE ALL
APPLICATIONS ARTICLES