Sunday, December 7, 2008

Crystal ActiveX Viewer - Manual Install

The first things you will need is the ActiveXViewer.cab file usually found somewhere on your server if you have an application that uses it. I haven't found it easily downloadable, not sure why?

Once you have the file, follow the instructions below on how to manually install the ActiveX viewer.

a. Check to see if the following three files Exist on the Client
- CRVIEWER.DLL
- SWEBRS.DLL
- SVIEWHLP.DLL

b. If they exist, then un-register the files:
- Regsvr32 /u pathtofile\filename
- Rename each file to .OLD

c. Copy these three files from the server to the client’s windows\system32 directory
- CRVIEWER.DLL
- SWEBRS.DLL
- SVIEWHLP.DLL

d. Register each file.
- Regsvr32 pathtofile\filename

Saturday, April 12, 2008

Performance Counter on XP with no PageFile What A PAIN!!!!

Yesterday, I was testing some software that uses performance counters and tracks history...etc....etc...very fancy.

When I realized that I didn't have a processor or memory performance object...

What the heck?

I mean these are standard Windows counters...after lots of work and digging I downloaded WindowsXP-KB838079-SupportTools-ENU.exe and using the tool that is part of the download called "exctrlst.exe". It allows you to enable performance objects and I enabled the PerfOS Object and life was good.

Saturday, February 23, 2008

SSRS - SQL Server Reporting Services Scheduling Error

I've worked with SSRS 2000 and 2005. I have done very little in the way of report creation using SSRS. Mainly have used the Report Manager to schedule subscriptions. I also have dealt with issues on the SQL side of SSRS. My role related to SSRS has been the support of the existing infrastructure for SSRS.

Error 8198 - The job failed. Unable to determine if the owner (domain\username) of job myjob has server access (reason: Could not obtain information about Windows NT group/user 'domain\username'. [SQLSTATE 42000] (Error 8198)).

If running the SSRS Report Server service under a network account, you will be unable to schedule reports. The work around for us was to change the SQL Agent job owner to 'sa'. The issue is that once you change the owner to 'sa', you are no longer able to change the job's schedule from reporting services without changing the owner of the job back to the network account used to run the Report Server. So, I created a few shared schedules in SSRS and changed those jobs to an owner of 'sa'. I just assign one of these schedules to my reports. The only time I have to change the owner of a job is when I am changing or creating a new schedule within the Report Manager. I believe this issue will go away in SQL 2005 SSRS but haven't tested it out. If you do test it and find it resolves the issue let me know and I will update the site.

After resolving the issue above I found an article on Microsoft's website that states the cause and workaround. Click here to read it.

Thursday, February 21, 2008

XML What's All That About Anyway?

I recently had to work with XML within SQL 2005. It was a learning experience for sure.

So what is XML?

- XML stands for Extensible Markup Language

- If you've ever seen HTML you'll see the similarity

- The purpose of XML as I understand it is to transport, store, and structure data.

XML seems to be getting bigger and bigger. It is everywhere you turn. Apparently it is a great way to structure data and pull/index data. My use for it was in a XML datatype column. It was an IP Address Management database and it was being used to track different devices such as printers, switches, routers, desktops, servers, etc...As such, these different devices types have different properties that needed to be tracked. The best solution was an XML datatype in SQL 2005 that defines the data for each of these devices.

Please feel free to make any corrections or post comments and I will make corrections. I am certainly not an XML expert.

Below is some sql code that I used to query a table...hopefully it will help someone out I wish I had the TSQL before I started.

Here is the csv that was exported from a test table I had setup to test.

Please feel free to post any comments or questions...Enjoy your XML experience!!!

Some links you might find useful(I borrowed some parts of the example from the first link...:

1. http://www.code-magazine.com/article.aspx?quickid=0605081&page=1
2. http://www.w3schools.com/xml/xml_whatis.asp
3. http://en.wikipedia.org/wiki/XML

Thursday, February 7, 2008

Change local administrator account password

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.

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).

Friday, February 1, 2008

Standard TCP/IP Port Missing

This post is specifically related to Standard TCP/IP Ports missing in any version of windows.

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port

Under that key there is a string value named "Driver" and the data value should be "tcpmon.dll".

I have seen this messed up on server migrations. It is a rare occurrence but a difficult one to figure out.

Also, check to make sure that the following files are in the C:\Windows\System32\ or C:\Winnt\System32\ directory:

tcpmib.dll
tcpmon.dll
tcpmon.ini
tcpmonui.dll

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.

Monday, January 28, 2008

Excel VBA printing and NE numbers

Anyone who has dealt with printing in VBA for Excel knows the plight of the NE00-NE99 ports/numbers that need to be appended to the printer name when passing it into the Application.ActivePrinter.

There are many ways to do this. I have found little bits and pieces here and there on the web and have come up with numerous ways of doing it myself. So I hope to guide you through the easier ways to do this as there seems to be little on the web about working around this problem.

The key:

HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\PrinterPorts

holds the values of the printers and NE port numbers. You could use these registry entries to figure out the NE port number for your printer. It requires some knowledge of using vba to access the registry for reading and using string functions to make a match.

I have also seem some people loop through all the NE numbers....from 00 to 99 to print out. It is possible but I think bad programming and I just don't like it.

The easiest way I've found is using the windows API via VBA.

How it works....

1. You need to declare the API function as below,

Private Declare Function SetDefaultPrinter Lib "winspool.drv" Alias "SetDefaultPrinterA"(ByVal pszPrinter As String) As Long

Note: Don't try to be smart and change the function name or alias or whatever just copy the lines...seriously it won't work if you mess with it.

2. Call the Function: SetDefaultPrinter strPrinter where strPrinter is the name of the print queue..if local the PrinterName and if located on a print server then \\server\queue_name

3. Print Something like the selected sheets or whatever floats your boat.

ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True

So now you are asking well but now my default printer changed even though it printer correctly...I can't live without my default printer...So here is what I implemented for my specific situation and should get you moving in the right direction. This was a module in Excel and I called it from Workbook_Open by using:

Call PrintModule.Print_Selected_Sheets("C:\Printer.txt")

where PrintModule is the name of my Module if you are creating a new module and copying/pasting the code your module will be Module1 most likely if it is a new workbook.

Also the way this code works is it prints the Selected Sheets so I added the following line prior to calling my PrintModule function.

Sheets(Array("Sheet1","Sheet2")).Select

You could obviously edit Sheet1 and Sheet2 with the sheets you want to print out. You could specify only Sheet1 or add more Sheets to print out....

Please post comments and I will do my best to reply. If you think there is a much better way then please post. I have seen lots of dead end posts with no real answer in my searches so hopefully this one will help out at least a few people. Also I apologize for the formatting as this is my first attempt at using Blogger.