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!

script

Status
Not open for further replies.

Briandr

MIS
Jul 11, 2003
177
US
Hi All,

This code appears to be test out fine, no errors. Not 100% sure it works the way I want or if can be tweaked better. I need two checks to be done. I want to read in the computer name first. If it is "ABC" or "DEF" it should jump down and check for Office 2003 viewers. If they exist then delete them. If a computer name was "TABC" or "TDEF" then it should do nothing.

Dim filesys
const Hidden = 0
const WaitOnReturn = true
Set objNet = CreateObject("WScript.Network")
strCompName = objNet.ComputerName
set WshShell = CreateObject("WScript.Shell")
Set filesys = CreateObject("Scripting.FileSystemObject")

If left(strCompName,3) = "ABC" or left(strCompName,6) = "DEF" Then

If filesys.FileExists("C:\Program Files\Microsoft Office\OFFICE11\XLVIEW.EXE") Then
WshShell.Run "MsiExec.exe /x {90840409-6000-11D3-8CFE-0150048383C9} /q",1,true
End If

If filesys.FileExists("C:\Program Files\Microsoft Office\OFFICE11\WORDVIEW.EXE") Then
WshShell.Run "MsiExec.exe /x {90850409-6000-11D3-8CFE-0150048383C9} /q",1,true
End If

If filesys.FileExists("C:\Program Files\Microsoft Office\OFFICE11\PPTVIEW.EXE") Then
WshShell.Run "MsiExec.exe /x {90AF0409-6000-11D3-8CFE-0150048383C9} /q",1,true
End If

End If
 
From your description, I think
Code:
If left(strCompName,3) = "ABC" or left(strCompName,[COLOR=red]6[/color]) = "DEF" Then
should be:
Code:
If left(strCompName,3) = "ABC" or left(strCompName,[COLOR=red]3[/color]) = "DEF" Then
 
Hey Brian, I have seen a couple of times now where you seem to get tripped up on the left and right functions. So I wanted to give you a simple explanation of them to make sure you get how they work.

If you have a string such as:

Code:
ourSting = "This text"

I can use right, mid or left to check the values of the text.

If I use Right(ourString,2) then I will be looking at the two characters on the right of the VALUE of the string. Again, it looks at the VALUE of the string, not the name of the string. So in this case Right(ourString,2) will give us "xt".

If I use Left(ourString,2) then it would be looking at the two characters starting from the left. In this case "Th".

If you want to look at text in the middle, you specify the string to search, the starting point (from the left) and how many characters to read. So, Mid(ourString,3,4) would give you "is t". Note that the space between the words is counted as a character.

I hope that helps to clear up the use of these functions. A great site for you to check out for additional help is
I hope that helps.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top