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!

Disable VBscript at logon for certian computers

Status
Not open for further replies.

cnewman65

IS-IT--Management
Mar 11, 2010
3
US
I have 7 computers that have bswusctx in the name bswusctx01, 02 etc..
I need code in the the script that will not run if it sees these computernames. It a basic Outlook Signature script like so.

On Error Resume Next

Dim objFSO, copyFile, vSystemDrive
Set WshShell = WScript.CreateObject("Wscript.Shell")
vAPPDATA = WshShell.ExpandEnvironmentStrings("%APPDATA%")
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.DeleteFolder(vAPPDATA & "\microsoft\signatures\*.*")
objFSO.DeleteFile(vAPPDATA & "\microsoft\signatures\*.*")



Set objSysInfo = CreateObject("ADSystemInfo")

Set WshShell = CreateObject("WScript.Shell")

strUser = objSysInfo.UserName
Set objUser = GetObject("LDAP://" & strUser)

strName = objUser.FirstName & " " & objUser.LastName
strTitle = objUser.Description
strCred = objUser.info
strStreet = objUser.StreetAddress
strLocation = objUser.l
strPostCode = objUser.PostalCode
strPhone = objUser.TelephoneNumber
strMobile = objUser.Mobile
strFax = objUser.FacsimileTelephoneNumber
strEmail = objUser.mail
objSelection.TypeText Chr(14)
Set objWord = CreateObject("Word.Application")
objSelection.TypeText Chr(14)
Set objDoc = objWord.Documents.Add()
Set objSelection = objWord.Selection
objSelection.TypeText Chr(14)
Set objEmailOptions = objWord.EmailOptions
Set objSignatureObject = objEmailOptions.EmailSignature

Set objSignatureEntries = objSignatureObject.EmailSignatureEntries

objSelection.Font.Bold = True
objSelection.Font.Name = "Veranda"
objSelection.Font.Size = 11
if (strCred) Then objSelection.TypeText strName & ", " & strCred Else objSelection.TypeText strName
objSelection.TypeText Chr(14)
objSelection.Font.Bold = False
objSelection.Font.Name = "Veranda"
objSelection.Font.Size = 11
objSelection.TypeText strTitle
objSelection.TypeText Chr(14)
objSelection.TypeText "BridgeStreet Worldwide"
objSelection.TypeText Chr(14)
objSelection.TypeText "T: " & strPhone
objSelection.TypeText Chr(14)
if (strFax) Then objSelection.TypeText "F: " & strFax & Chr(11)
if (strMobile) Then objSelection.TypeText "C: " & strMobile & Chr(11)
Set hyp = objSelection.Hyperlinks.Add(objSelection.range, "mailto:" & strEmail, , ,strEmail)
hyp.Range.Font.Size = "11"
hyp.Range.Font.Name = "Veranda"
objSelection.TypeText Chr(14)
Set hyp = objSelection.Hyperlinks.Add(objSelection.Range, "" & "hyp.Range.Font.Size = "11"
hyp.Range.Font.Name = "Veranda"
objSelection.TypeText Chr(14)
objSelection.Font.Bold = True
objSelection.Font.Name = "Veranda"
objSelection.Font.Size = 11
objSelection.TypeText "Best Serviced Apartment Company - "
objSelection.Hyperlinks.Add objSelection.Range, " " & " & " ", , , "Business Travel Awards 2010", "_blank"
Set objSelection = objDoc.Range(objSelection.End-28,objSelection.End)
objSelection.Font.Bold = True
objSelection.Font.Name = "Veranda"
objSelection.Font.Size = 11
objSelection.Font.Underline = false

Set objSelection = objDoc.Range()

objSignatureEntries.Add "Full Signature", objSelection
objSignatureObject.NewMessageSignature = "Full Signature"

objSignatureEntries.Add "Reply Signature", objSelection
objSignatureObject.ReplyMessageSignature = "Reply Signature"

objDoc.Saved = True
objWord.Quit
 
Have you tried to test the value of WshShell.ExpandEnvironmentStrings("%ComputerName%") ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I do not know how to do that. I see allot of threads on this but do not know how to implement it.
 
I use something similar to this in my logonscripts for differnt computer models.
Just put it at the top of the script and any computername that matches the first 8 char will quit the script.

Set objNetwork = CreateObject("Wscript.Network")

If Left(objNetwork.ComputerName,8) = "bswusctx" Then
WScript.Quit
End If

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top