The script below changes the local administrator account for the PCs in Computers.txt and logs success to one log file, failure to another, and a third with the list of PCs that were registered as failures so that you can use that list to run the script again at a different time after fixing the errors. Some errors are ping failures and these obviously will be PCs that are not on the network. You will need to change the directories in the script or create the directory structure for this script to work. Note: When you run this you will need to be using an account that has administrative access to the PCs. I used my account that is in a group that is setup to be an administrator on all PCs.
Thursday, February 7, 2008
Tuesday, February 5, 2008
VBScript to change Excel Macro Security
The script below will change the Excel Macro Security to Low. I created it for the purpose of changing the macro security level to Low for running reports. The server was also used to edit Excel reports and thus the security always got changed to medium or high while people edited reports and often forgot to change it back to Low. Hence, the popup asking to enable/disable macros causing the report to sit there waiting for user input. This script ran prior to the scheduled reports running to ensure the security level was where it should be.
Sending E-mail via VBScript using CDO
This is a template for sending e-mail via vbscript using CDO. You will need to replace the subject/to/from to your liking. I also showed how to place an attachment in the email. Just change the path to the file you want to attach. You will also need to replace "smtp.yourdomain.com" with a valid smtp server. Most companies have some kind of smtp server and there may even be some free ones...that are publicly accessible but I doubt it...as they would be huge targets for spam deliveries. My original use for this script was to distribute log files and it was called by another script if the log was parsed and errors were found.
Saturday, February 2, 2008
Ping and check for success in VBScript
Here is a quick piece of VBScript code that does a ping via the shell object. Then parses the results that were dumped into a text file to check for success. It pings PCs that are in the C:\Computers.txt file. One PC name per line. In the strSuccess=No part you would place the activities for a failed ping which will likely be nothing or possibly writing to a log. In the strSuccess=Yes you would place whatever code needs to be done on the PC name...in my case it is usually some kind of wmi or registry edit. There are other ways to do this such as the WMI class Win32_PingStatus(Only works on XP or later).
Wednesday, January 30, 2008
Start and Stop Windows Services
Try This, just change all the NetDDE items to your service. In this example: When NetDDE is stopped it will start NetDDE and then start all services that depend on NetDDE. When NetDDE is running it will stop all services that depend on NetDDE and then will stop NetDDE.