#1 17 Feb 2011 10:12

Iglooo
Member
Registered: 15 Feb 2011
Posts: 1

Hi, need some help with completing this script.

Hi guys!

I haven't scripted in a couple of years no, so dusting it off by trying to do "somewhat easy stuff".

This is how I want the script to work.

  • Give me the computer name

Set wshShell = WScript.CreateObject( "WScript.Shell" )
    strComputerName = wshShell.ExpandEnvironmentStrings( "%COMPUTERNAME%" )
        WScript.Echo "Computer Name: " & strComputerName

This gives me exactly what I want.

  • Then I want it to listen for a process

set service = GetObject ("winmgmts:")

for each Process in Service.InstancesOf ("Win32_Process")
    If Process.Name = "xxxxx.exe" then
        wscript.echo "xxxxx running"
        wscript.quit
    End If
next
wscript.echo "xxxxxx not running"

This also works just fine. And gives me the result I want.

Here is where I need some help, I want to be able to create an if statement based on "Not running" and then,
have it sequence a .bat file from a server to initiate an installation. And this is where I understand why I should have kept my scripting up-2-date and not shelved it.

But there is another thing, could it be possible. Instead of making it echo the results,
have them display the comp name and if the process is running or not with a MsgBox statement?

I am for the moment, blinded so I can't see what I am missing out of.
Any help would be greatly appreciated.

//Iglooo

Offline

#2 21 Feb 2011 20:09

Simon Sheppard
Super Administrator
Registered: 27 Aug 2005
Posts: 1,012
Website

Re: Hi, need some help with completing this script.

All you need is to expand your IF...THEN to an IF...THEN...ELSE

http://ss64.com/vb/if.html

Offline

Board footer

Powered by FluxBB