Friday, October 25, 2013

Personal Version Control on the cheap (FREE!)

I've always been a fan of version control for my own documents. I can't even begin to tell you how many times I have edited and saved something (code, word documents, really anything) then went back to look for something that I in my infinite wisdom decided to delete because "it would never be needed". Well guess what? I was wrong.

Recently, I've been working much more on scripts mainly TSQL but also find myself building support documents, random documentation, spreadsheets for automation, etc...basically things that change periodically and that I would like to keep previous versions just in case :)

There are all kinds of version control software but I've been a fan of Tortoise SVN in the past and still am. It integrates well with Windows, yes I'm a Windows user; version control isn't only for Linux. TortoiseSVN is actually an Apache Subversion client. While this implies you need a server and really could have one running Subversion, you can also utilize Tortoise SVN to create a local Subversion repository. Note: This means if you care about your repository you will need to back it up.

Here are the steps to create yourself a local version controlled folder:

1. Download and Install the latest version of TortoiseSVN; this will be a next --> next --> Finish type install.

2. Create a new folder that you would like to be the root of your repository. For our example we'll call it C:\SVNRepository.

3. Right Click the folder you created (C:\SVNRepository), you should see a TortoiseSVN menu. Mouseover that menu and you will have numerous options. Choose "Create Repository Here"

4. You will receive a window to confirm. Here you could create the default folder structure of trunk/branch/tags. But I don't and unless you are well versed in using these different constructs I think it just becomes confusing. So, I recommend hitting Ok at this point or go read up on the trunk/branch/tags construct and see if it is something you'd like to try out. This isn't a life or death decision, these are basically just folders and if you end up not liking them well just delete them.

5. Assuming you eventually hit Ok, your folder will now have a different icon that is good. Create a folder in Windows that will serve as your working directory. For our example we'll call it C:\WorkingDirectory.

6. Right Click on C:\WorkingDirectory --> Left Click "SVN Checkout..."

7. You should now have a "Checkout" window open. For "URL of repository:" enter "file:///C:/SVNRepository". The "Checkout directory" should already be set to C:\WorkingDirectory. Click Ok.

8. Double click C:\WorkingDirectory, you now have an empty folder. You can create folders and files in here as you wish. Create something, anything for now.

9. So you've created something in step 8 and your folder is no longer empty. But it is not saved to the repository yet. Right click on C:\WorkingDirectory --> Left click "SVN Commit"

10. You will now have a "Commit" window. It will show you all the changes you have made and a comment box, you should only see new things that say non-versioned at this point and you can add a comment as appropriate. Click the check boxes next to the items you want to save to the repository and click ok. Click Ok again.

11. If you haven't already done so create a document or copy one over, make sure to commit changes as in step 9. You can also right click on a specific file and commit it rather than the entire structure. Modify this file a few times and commit so that we have some changes to revert or compare.

12. Now you should have one file that has multiple revisions, first make sure you left click the file --> then right click on this file --> Mouseover TortoiseSVN --> Left Click "Show Log".

13. You will now have a "Log Messages" window open and you can click on each version of your file. Right clicking any of these versions gives you a plethora of choices including comparing to current version, comparing to a previous version, reverting, saving off a revision as something else, etc...play around and see what you can do.

This is by no means an extensive tutorial on using TortoiseSVN or Apache Subversion but rather a quick and dirty setup guide and just enough to get you going and playing. There are other features you could use such as add (if you have a new file or folder that you create in the structure) this has the advantage of showing you that you have a new file that now doesn't match the repository without committing. You can also import files/folders from an existing location. There are tons of things you can do but you can read more about that at the Apache Subversion Documentation and TortoiseSVN Support websites. You may even find you want or need to setup an Apache Subversion server if you want to use it for more than your personal repository.

Thursday, October 24, 2013

Has Rundll32 run away with your CPU?

So, the truth is you will probably get a call about application slowness and you will see rundll32.exe is taking up all the CPU. You will then proceed to call your server team and tell them to fix it. They will likely tell you that your application is causing it and that rundll32 could be any of a number of things. You will probably yell at them insisting that rundll32 is not part of your application. Luckily I've been a server guy and an application guy so I figured that out myself. But be warned this conversation has and will happen many times.

Easiest thing to start off with is simply trying to figure out what in the world rundll32.exe is actually attempting to do. There are probably many ways to find this but I simply opened up task manager --> clicked on the process tab --> went to the View menu --> Select Columns --> Check the box next to Command Line --> Click Ok.

You will now have an extra column for each process. Find your rundll32.exe process and look at the Command Line column. Hopefully you will see something you recognize but you may find something obscure that requires lots of research...your mileage may vary.

Back to my problem, here is what I found:

rundll32 C:\Windows\system32\spool\DRIVERS\x64\3\hpmsn130.dll,MonitorPrintJobStatus /pjob=31 /pname"printer-c"

That very quickly stood out as a printer related issue because of the spool directory, printer name which wasn't printer-c but changed for this example, MonitorPrintJobStatus, and well those dang hp dlls.

So for a while I cursed printers and HP unified print drivers but realized that wasn't going to fix my problem. I changed the print processor to winprint from the HP specific print processor but that didn't result in a fix.

I proceeded to poke around the printer properties and ran across and option called "Printer Status Notification:" which was the cause of the CPU hogging. I disabled this feature and all was good.

So I went back to cursing HP unified print drivers! But I will save that for another day (we'll call that day never)...I don't like printers.

Wednesday, October 23, 2013

TSQL to find database size

Earlier today I had the need to calculate both the size of my SQL database files as well as the amount of used space in the aforementioned database files. While I was at it I added a percent used column. I found lots of posts out there some horribly complicated and some way too simple and not providing enough detail.

The FILEPROPERTY (http://technet.microsoft.com/en-us/library/ms188401.aspx) was the key here and what I used to simply calculate the amount of space used within the database files.

Also make sure you replace the "<your_database_name_here>" at the beginning of the query or make sure you have the appropriate database selected in SSMS.

Friday, June 12, 2009

RDP Autologon; talk about a security issue

Recently I have been doing server admin work and discovered numerous servers at a facility had Terminal Services configured such that it automatically used credentials that were saved on the server for all Remote Desktop/Terminal Services clients.

I understand this might be ok on a real Terminal Server that provides user access to some limited applications but in this case it was an application server that had terminal services setup for remote administration.

The settings are in Terminal Services Configuration, then right click on the RDP-TCP and select properties. You will see a Logon Settings tab that defaults to "Use client-provided logon information" but you can select "Always use the following logon information" and then proceed to enter in a username/domain/password.

What more can I say "You should never enter in an Administrative user account into this section of the terminal services configuration!" If you have seen a legitimate reason for doing so I would love to hear your story...just post a comment.

Friday, January 23, 2009

Just some random VBA

Below is some vba code I wrote for a Excel 2007 spreadsheet. Essentially, it uses a proprietary add-in that will refresh data on calculate based on some date values. Then it moves that data to a temp sheet and does some massaging of the data. Then creates a pivot table that aggregates the data and a chart to show the data. I have written extensive comments to show what the code does.

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.