Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

application running on a server 1

Status
Not open for further replies.

anilreddygeeda

Programmer
Sep 23, 2009
4
US
Hiii all, guys please help me regarding the script for this. To determine whether an application is running on a server by a user,If it is not running he has to launch it, If it is already running by him in the server, he has to use it.Thanks in advance.....
 
Query the local machine to get the current user. Query the remote machine to get a list of processes running. If the is a process running NOT owned by the current user, launch it.

Code:
strComputer = "."
strProcessName = "Notepad.exe"

set objNetwork = WScript.CreateObject("WScript.Network")
set objWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
set colProcesses = objWMI.ExecQuery("Select * from Win32_Process Where Name='" & strProcessName & "'")

for each objProcess in colProcesses
   intReturn = objProcess.GetOwner(strOwner)
   if (strOwner <> objNetwork.UserName) then
      objShell.Run("c:\windows\notepad.exe")
   end if
next
-Geates
 
Thanks Geates for your help. Where do you want me to run this vb script you sent me. You want me to run in local machine or the remote machine.
 
Hello Mr.Geates, Do you mind providing me the entire code for the process you decribed to me. Since I am a beginner to this, I am really finding it difficult to get on with this......Thanks in advance......
 
That pretty much is the entire code. No extra code is need if the script is run on the server. However, if the script is run remotely then
Code:
strComputer = "server_name"
To run a program on a remote machine you'll need to download SystemInternals and use psexec.exee
Code:
objShell.Run("%comspec% /c c:\path\to\psexec.exe \\server_name "path\to\program" /u domain\username password)

-Geates
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top