Advertisements

MySql Stuff

ERROR 1170 (42000): BLOB/TEXT column ‘field_name’ used in key specification without a key length.

Use Varchar(some length under 257) and this will allow it to be a key field.

DROP TRIGGER Syntax

DROP TRIGGER [IF EXISTS] [schema_name.]trigger_name

Good PDF on creating MySql Triggers http://www.paragon-cs.com/mag/issue6.pdf

CREATE TRIGGER emplog_insert AFTER INSERT ON emp
FOR EACH ROW
INSERT INTO emplog VALUES (NEW.id, NEW.lastname, NEW.firstname, NEW.gender, NEW.dob,
NEW.marital, NEW.SSN, ‘I’, NULL, USER());

Advertisements

I was trying to access WMI information from a service and kept on getting errors

System.UnauthorizedAccessException: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))

I then went duh, the service account that it is running under wouldn’t have access to the network.

I suppose you could change the account on the service itself, but for a quick fix I changed

With WMIConnectionOptions

.Impersonation = System.Management.ImpersonationLevel.Impersonate
.Authentication = System.Management.AuthenticationLevel.Packet

End With

To:

With WMIConnectionOptions

.username = “my username”

.Password = “my password”

.Impersonation = System.Management.ImpersonationLevel.Impersonate
.Authentication = System.Management.AuthenticationLevel.Packet

End With

And that did the trick

ESX 3.5 Convert Bus logic to LSI Logic SCSI controller

Find this post interesting? Do you like interesting things? Maybe you would like my invention, a connectible candle called a WickBrick!

Get one here http://wickbrick.etsy.com/

WickBrick

As mentioned in this post, http://vconfessions.wordpress.com/2008/02/14/changing-vmware-scsi-controller/

I was also able to just edit the settings and set the SCSI controller to LSI without any problems. This was with Server 2003. When I started up the machine there was a message asking me if I wanted to convert the controller which I answered yes to.

Creating a service for Visual Basic 2008 Express

Find this post interesting? Do you like interesting things? Maybe you would like my invention, a connectible candle called a WickBrick!

Get one here http://wickbrick.etsy.com/

WickBrick

One of the drawbacks to using VB 2008 express is that some of the functionality is removed. This is perfectly fair, I mean you can download and use it for free!

Well how do you go about creating a service with it then? Well this kind soul has so helpfully created a template that you can load into visual studio.

http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=4511&lngWId=10

Alternate download here http://sites.google.com/site/mellerbeck/Home/Windows_Se1973412152006.zip?attredirects=0

Ok, so the trick with that is to place the zip file under “My Documents\Visual Studio 2005\Templates\ProjectTemplates\C:\Documents and Settings\Luiz.BRASVALOR\Meus documentos\Visual Studio 2005\Templates\ProjectTemplates\Visual Basic”

Now, when you go to new projects you should be able to see the Windows Service as a template. So select that, now for a quick test you could follow this example

http://www.dotheweb.net/articles/dotnet/services.aspx

Basically add a timer (Right clicking on the Toolbox, and Choose Items, add System.Timers.Timer) Do not use the forms timer!

Add the Following Code to the Timer1_Elapsed:

Dim eventlog1 As New EventLog
If Not EventLog.SourceExists(“MyApp1”) Then
EventLog.CreateEventSource(“MyApp1”, “Application”)
End If
EventLog1.Source = “MyApp1”
EventLog1.WriteEntry(“This is a simple event log entry”)

End Sub

And For OnStart():

Protected Overrides Sub OnStart(ByVal args() As String)
‘ Add code here to start your service. This method should set things
‘ in motion so your service can do its work.
Timer1.Enabled = True
End Sub

Here is where you have to take a different path though, since we are using Express we can’t go right click add installer. Instead, as it shows here http://msdn.microsoft.com/en-us/library/system.serviceprocess.serviceinstaller(VS.71).aspx

You need to add your own installer code. So, right click on your project in the solutions explorer and go add new class.

Then copy and paste this in.

Imports System
Imports System.Collections
Imports System.Configuration.Install
Imports System.ServiceProcess
Imports System.ComponentModel

<RunInstallerAttribute(True)> _
Public Class MyProjectInstaller
Inherits Installer
Private serviceInstaller1 As ServiceInstaller
Private processInstaller As ServiceProcessInstaller

Public Sub New()
‘ Instantiate installers for process and services.
processInstaller = New ServiceProcessInstaller()
serviceInstaller1 = New ServiceInstaller()

‘ The services will run under the system account.
processInstaller.Account = ServiceAccount.LocalSystem

‘ The services will be started manually.
serviceInstaller1.StartType = ServiceStartMode.Manual

‘ ServiceName must equal those on ServiceBase derived classes.
serviceInstaller1.ServiceName = “Your Service”

‘ Add installers to collection. Order is not important.
Installers.Add(serviceInstaller1)
Installers.Add(processInstaller)
End Sub
End Class

The only important thing that you might need to change is the ServiceName = “Your Service” change to what ever you want your service to be called.

Ok, build your service.

Now you need to install your service. One way is to use the installutil.exe, this is located in

C:\WINDOWS\Microsoft.NET\Framework\   your dot net version here \ InstallUtil.exe

So run InstallUtil.exe and pass it the path to your compiled service. If all goes well if you go start, run, services.msc, your should see what ever you named your service show up. Go ahead and start your service and you should see sample messages appear in your event log.

Now, my newest favorite method of installing services is using an undocumented method call

This post talks about it http://anotherlab.rajapet.net/2006/06/self-installing-services-in-net.html

Add a reference to System.Configuration.Install and then

Imports System.Configuration.Install

Just create a form with two buttons and then paste
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Try
System.Configuration.Install.ManagedInstallerClass.InstallHelper(New String() {“C:\Test\YourService1.exe”})
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Try
System.Configuration.Install.ManagedInstallerClass.InstallHelper(New String() {“/u”, “C:\Test\YourService1.exe”})
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
End Sub

Then you can just click on the buttons to install and remove your service!

Chapter 2: The perfect Corporate XP Workstation Install

Find this post interesting? Do you like interesting things? Maybe you would like my invention, a connectible candle called a WickBrick!

Get one here http://wickbrick.etsy.com/

WickBrick

Network Cookbook for Small and Medium Enterprises.

Lowering costs by making technology easier to maintain.

Optimizing a workstation before cloning and deployment can be a chore. Here is what I do.

Create a user named newdefault, this user will be copied over the hidden default profile to apply the settings to future users.

I only like the classic windows look so first thing, right click start, properties, and select Classic. Ahh much better

Next, right click the desktop, properties, themes tab, select Windows Classic, set desktop background to None.

Click Customize Desktop on the bottom, and uncheck the ‘Run Desktop Cleanup Wizard’

Next, right click My computer, properties, advanced, settings, under visual effects, select adjust for best performance.

Next, click the system restore tab, click the turn off system restore on all drives. (I block this at the AD level anyways though)

Next, double click My computer, right click on any drives, properties, and uncheck the ‘Allow Indexing Service to index this disk…’ (This search is terrible anyways, I’m looking for a good corporate replacement, google desktop works OK)

Disable Hibernation To disable, Right click the desktop and choose “Properties”. Select the “Screensaver” tab. Press “Power” and select the “Hibernate” tab. Uncheck “Hibernation”. (Not for a laptop)

Disable annoying Sounds

Start > Control Panel > Sounds, Speech, and Audio Devices > Change the sound scheme. Beneath “Sound Scheme”, choose “No Sounds”.

Ok, now that the visual, audio, and operational tweaks are taken care of lets add some enhancements.

Hide the annoying help & support button off of the start menu

For Windows Classic Start menu, you need to modify the registry directly:

Click Start, Run and type Regedit.exe
Navigate to the following location:

HKEY_CURRENT_USER \ Software \ Microsoft \ Windows \ CurrentVersion \ Explorer \ Advanced

In the right-pane, create a new REG_DWORD value named NoStartMenuHelp
Double-click NoStartMenuHelp and set it’s value to 1
Close Regedit.

GET BACK CLASSIC SEARCH (REMOVE THE STUPID DOG!) this is for XP, server 2003 has the classic search

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\CabinetState
Add a new string (REG_SZ) called “Use Search Asst” – set the value to “no” and you will have the classic  search

Expand the control panel so that all the options are displayed off of the start menu

Right click start, properties, click customize next to the Classic Start menu, Click the check box next to Expand Control Panel (expanding network connections isn’t bad either)

Add copy To Folder and Move To Folder options off the right-click menu

To add the option, run the Registry Editor [Hack #68] and go to HKEY_CLASSES_ROOT\AllFilesystemObjects\shellex\ContextMenuHandlers. shellex tells you it’s a shell extension key that lets you customize the user shell or the interface. Create a new key called Copy To. Set the value to {C2FBB630-2971-11d1-A18C-00C04FD75D13}. Create another new key called Move To. Set the value to {C2FBB631-2971-11d1-A18C-00C04FD75D13}. Exit the Registry. The changes should take effect immediately. The Copy To Folder and Move To Folder options will appear. When you right-click on a file and choose one of the options, you’ll be able to move or copy the file

Add Open Command Window Here

Go here and download http://www.microsoft.com/windowsxp/downloads/powertoys/xppowertoys.mspx Open Command Window Here

Also install the image resizer, (It’s hidden in the right column… who designed this site it’s terrible)

Install UltraVNC, I love using this program to remote control our desktops. It’s fast, free, and uses AD authentication. I change the port to be different from the default. http://www.uvnc.com/

I use my Global Domination App to monitor and remote control our workstations. https://michaelellerbeck.com/software-projects/

Install VLC, this way when users come to you trying to play strange file types this will usually handle it. http://www.videolan.org/vlc/

Install 7zip, take it from me, the built in windows xp zipping thingy is terrible. After install, open up the 7-zip File Manager, go options, under plugins click options, then check Open archive, Extract to <Folder>, and compress to <Archive>.zip and email (I don’t use any of the other menu options). http://www.7-zip.org/

You may or may not want to install firefox 3, if you do, install the adblock plus plugin. https://addons.mozilla.org/en-US/firefox/addon/1865

For burning CD’s I really like CD Burner XP Pro. http://cdburnerxp.se/

Install Defraggler, and set it to defrag the computer at night. http://www.defraggler.com/ (This is my not so scientific comparison of defraggler to other non free defraggers https://michaelellerbeck.com/2008/11/20/compare-defraggler-to-diskkeeper-and-perfect-disk/

To help bring your users into PDF goodness, install PDF Creator for printing to PDF’s http://sourceforge.net/projects/pdfcreator/

and then for opening PDF’s and annotating them! install PDF-XChange Viewer. (I like version 1.0 from 2007) http://www.docu-track.com/downloads/users/

Install the .net framework 1.1, 2.0, and 3.5

Launch Folder Windows in a Separate Process

1. Open an explorer by going to Start > My Computer
2. At the top on the menu bar, go to Tools > Folder Options
3. Activate the “View” tab
4. Below, scroll down and check “Launch folder windows in a separate Process”  Apply the changes.

To let your users take screen shots easier you can install snippy. http://www.bhelpuri.net/Snippy/

To allow the moving of taskbar buttons install Taskbar Shuffle. http://www.freewebs.com/nerdcave/taskbarshuffle.htm

Turn on Internet explorer inline AutoComplete. To do so run Internet Explorer, Internet Options, Advanced tab, enable “Use inline AutoComplete”

Turn off “reuse windows for launching shortcuts” (I do this at an AD level)

Enable remote desktop

HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server. Under the Terminal Server key, you’ll find a REG_DWORD value named fDenyTSConnection. Double-click on that value to open the Edit DWORD Value box and change the value data from 1 (Remote Desktop disabled) to 0 (Remote Desktop enabled)

(I do this through the AD as well)

To enable or disable Remote Desktop
Using Group Policies (best practice)

1. Open Group Policy.
2. In Computer Configuration, Administrative Templates, Windows Components, Terminal Services, double-click the Allows users to connect remotely using Terminal Services setting.
3. Do one of the following:
* To enable Remote Desktop, click Enabled.
* To disable Remote Desktop, click Disabled.
If you disable Remote Desktop while users are connected to the target computers, the computers maintain their current connections, but will not accept any new incoming connections.

Disable search Network Printers in Windows Explorer

Open My Computer, Tools, Folder Options, View tab, Uncheck “Automatically search for network folders and printers”, OK, “Apply to All Folders” button

Disable last access registry tweak

This change stops the recording of the last access of files on your network/local disk. File changes will still be recorded. If you need to record the last access of a file then disable this.

Regedit, HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem
3. Create a new DWORD value in the right-hand pane named NtfsDisableLastAccessUpdate and give it a value of 1.
To remove this tweak just delete the key or give it a value of 0.

Restart your computer.

In addition

You may or may not have noticed that the default picture and fax viewer for XP can be quite lame. If for example you want to print a multi-page fax you have to click through a huge amount of buttons. If you, or anyone you support, needs a fax viewer that has easier printing support you can install the one that is included in Microsoft Office. To do this run Office Setup, Add or Remove Features, expand click office tools, click Microsoft Office Document Imagining select run from my computer, update.

Also add the compatibility crap for office 2007 files docx etc…

I like to install ImageResizer. Also remove the menu delay http://support.microsoft.com/kb/216445


Whew that is a lot of stuff. What do you put on your Perfect Corporate XP Workstation install?