Do you have a scripting-related question or problem? You can send your question or problem to [email protected]
Q: How do you use VBScript to set and obtain Registry entries?
You can use VBScript with Windows Scripting Host (WSH). The WshShell object's RegRead, RegWrite, and RegDelete methods read, write, and delete Registry keys and values, respectively. You can find usage instructions and example code in the WSH technical paper "Windows Script Host Programmer's Reference" on the Microsoft Windows Script Technologies Web site. Go to http://msdn.microsoft.com/ scripting, and select Windows Script Host from the left navigation pane. In the right navigation pane, click Documentation. Select Technical Paper to view "Windows Script Host Programmer's Reference" online. You can also download the technical paper from this location.
Q: How can you automate the process of identifying the owners of files and directories?
You can write a script that uses the subinacl.exe utility, which displays and changes file and directory ownership. For more information about this console utility, run
C:\> subinacl /help
on a system that has Microsoft Windows NT Server 4.0 Resource Kit, Supplement Three installed.
Q: How can I merge two text files on two NT servers into one file?
You can use the Copy command in conjunction with the plus sign (+) to copy and append multiple files. The following code copies and appends a remote file named file2.txt to a local file named file1.txt in a new file named file3.txt:
C:\> copy file1.txt+\\dell610\c$file2.txt c:\file3.txt
You can learn more about the Copy command in the online Help or by typing
at the command prompt.
Q: A friend sent me a Common Gateway Interface (CGI) program that runs with Perl. I installed Perl for Win32 (aka ActivePerl) on my NT server, but the CGI program doesn't work. How can I get ActivePerl and this program to work together?
If you're running Microsoft Internet Information Server (IIS) 4.0, ActivePerl configures your server to run Perl and CGI programs during ActivePerl Setup. Simply make sure you've selected the Associate '.pl' with Perl.exe for your Web server(s) option in the Select Perl Options dialog box during setup.
To configure IIS 4.0 manually, run the Internet Services Manager, right-click the Default Web Site, and choose Properties. In the Default Web Site Properties dialog box, select the Home Directory tab. At the bottom of the Home Directory page, select Configuration in the Application Settings section. In the Application Configuration dialog box, click Add. Enter the following values in the Add/Edit Application Extension Mapping dialog box:
- For Executable, enter C:\Perl\bin\perl.exe %s %s.
- For Extension, enter .pl.
If you're running an IIS version earlier than 4.0 or another Web server, check out ActiveState's perlwin32faq6 - web server info at http://www.activestate.com/ support/faqs/win32/ perlwin32 faq6.html for setup information.
Q: If you're using VBScript with WSH, which approach is best for sending email: using Collaboration Data Objects (CDO), Outlook objects, or Collaboration Data Objects for Windows NT Server (CDONTS)? I prefer using CDONTS because I assume that the other options require a Microsoft Exchange Server profile on the machine and the CDO or Outlook library. But can I use CDONTS if CDONTS and the IIS SMTP service that it uses are on another PC?
Your assumption is correct: You need the Exchange profile and the CDO or Outlook library to send email using CDO or Outlook objects. Unfortunately, using VBScript with WSH to create an object (in your case, CDONTS.NewMail) on a remote machine is impossible even though the VBScript documentation states otherwise. Supposedly, Microsoft plans to address this problem in a future release of VBScript.
For now, you need to install the CDONTS library on the local machine if you want to run VBScript/WSH code that uses CDONTS. An alternative might be to use a command-line utility, such as Sendmail. Many such utilities are available on the Internet, and you can use your favorite search engine to find one.
For more information about CDO and CDONTS, see the Microsoft Exchange Collaboration Web site at http://www.microsoft.com/ exchange/ collaboration.htm. You can download the white paper "Introduction to Collaboration Data Objects" from http:// www. microsoft.com/ exchange/55/ whpprs/ cdo.htm. For detailed CDO 1.2.1 and CDONTS programming information and code samples, visit the Microsoft Developer Network (MSDN) Online Library at http:// msdn.microsoft.com/ library/default.htm. In the left navigation menu, select Platform SDK, Messaging and Collaboration Services, CDO 1.2.1.
If you have a scripting-related question, send it to [email protected] The question you submit will go to a team of scripting experts, who'll decide whether to use the question in the Rem column. Unfortunately, because of the volume of questions submitted, we can't answer and include all questions submitted to Rem.