Question : VBS Script stops when it encounters an offline computer

Purpose of script, it's set up to look at a text file and pull a computer name one at a time and change a registry value.

someone help change a script i had to accomplish this. Now it works but when it encounters a computer offline the script stops....... any ideas how we can change it to skip the offline computer and move on to the next one ?

Basically skip any computers and move on if it encounters any problems ??

Originally Help located on this thread =  http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_26339410.html
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
Const ForReading = 1
Const HKEY_LOCAL_MACHINE = &H80000002

strTxtFile = "C:\Documents and Settings\soullm01\Desktop\New Text Document.txt"

'Reads the TXT file
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(strTxtFile, ForReading)
strAllComputers = objFile.ReadAll
objFile.Close

arrComputers = Split(strAllComputers,VbCrLf)

For Each strComputer In arrComputers
WScript.Echo  strComputer
	Set objRegistry = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
	 
	strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\policies\system"
	strValueName = "ScForceOption"
	
	strValue = 0
	
	objRegistry.SetDWORDValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
	
	If IsNull(strValue) Then
	    Wscript.Echo "The registry key does not exist."
	ElseIf strValue = 1 Then
	    Wscript.Echo "Force Smart Card Logon is now enabled on " & strComputer
	ElseIf strValue = 0 Then
	    Wscript.Echo "Force Smart Card Logon is now disabled on " & strComputer
	End If
	
	rem Use DOS prompt with admin rights. Useage: cscript ***.vbs //nologo //S

Next

Answer : VBS Script stops when it encounters an offline computer

Hi, occ_user.

This cannot be done with a rule.  Rules only fire when a message is received or after it's sent.  This requires a macro.  The macro is simple enough, but it will have to be deployed to every computer.  Outlook does not have an automated means of distributing macros.  Deploying the macro will have to be done manually.  The more computers there are in the organization the more of a pain this becomes.  Also, a savvy user could turn the macro off.

The above aside, here's the macro.  Follow these instructions to use it.

Outlook 2007
1.  Start Outlook
2.  Click Tools > Macro > Visual Basic Editor
3.  If not already expanded, expand Microsoft Office Outlook Objects and click on ThisOutlookSession
4.  Copy the code from the Code Snippet box and paste it into the right-hand pane of Outlook's VB Editor window
5.  Edit the code as needed.  I included comment lines wherever something needs to or can change
6.  Click the diskette icon on the toolbar to save the changes
7.  Close the VB Editor
8.  Click Tools > Trust Center
9.  Click Macro Security
10. Set Macro Security to "Warnings for all macros"
11. Click OK
12. Close Outlook
13. Start Outlook.  Outlook will display a dialog-box warning that ThisOutlookSession contains macros and asking if you want to allow them to run.  Say yes.


Outlook 2003 and Earlier
1.  Start Outlook
2.  Click Tools > Macro > Visual Basic Editor
3.  If not already expanded, expand Microsoft Office Outlook Objects and click on ThisOutlookSession
4.  Copy the code from the Code Snippet box and paste it into the right-hand pane of
5.  Outlook's VB Editor window
6.  Edit the code as needed.  I included comment lines wherever something needs to or can change
7.  Click the diskette icon on the toolbar to save the changes
8.  Close the VB Editor
9.  Click Tools > Macro > Security
10. Set the Security Level to Medium
11. Close Outlook
12. Start Outlook
13. Outlook will display a dialog-box warning that ThisOutlookSession contains macros and asking if you want to allow them to run.  Say yes.
1:
2:
3:
4:
5:
6:
7:
8:
9:
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
    If Item.Class = olMail Then
        If InStr(1, Item.Subject, ":") Then
            'Edit the warning message and title on the next line as needed.'
            msgbox "The subject contains a colon.  Please remove it and then send again.", vbCritical + vbOKOnly, "Company Policy"
            Cancel = True
        End If
    End If
End Sub
Random Solutions  
 
programming4us programming4us