Saturday, August 5, 2006

Hibernating/suspending from the command line on Windows XP

Enter:

rundll32 powrprof.dll,SetSuspendState

Whether it hibernates or suspends depends on Control Panel power options.

Attachments:

if (document.getElementById("idAttachmentsTable").rows.length == 0) document.getElementById("idAttachmentsRow").style.display='none';

Hibernating from the command line in Windows Vista

shutdown /h

Friday, April 14, 2006

Changing Linux to Text Console Login

Log in to the PC as root.
Edit /etc/inittab
Change the 5 in the line:

id:5:initdefault:

to 3.

The id:5 denotes the runlevel that Linux will boot up into. Runlevel 5 is the graphical login mode. This means that when Linux starts it will go directly into X11. The initdefault stands for the default runlevel. Change this runlevel to 3 for multiuser mode console login.

Thursday, December 8, 2005

Windows Tablet as a portable gaming device?

I reckon Microsoft is missing a trick here. They should, in my opinion, push Windows Tablet Edition as a portable gaming platform rather than the lacklustre Windows CE. The larger form factor is much more conducive to immersive gaming and the Windows platform easier to port existing games across than the crippled CE platform.

Thursday, October 27, 2005

VBScript to set all local users' passwords to non-expire

Const ADS_UF_DONT_EXPIRE_PASSWD = &h10000
Set objNetwork = CreateObject("Wscript.Network")
strComputer = objNetwork.ComputerName
Set colAccounts = GetObject("WinNT://" & strComputer & "")
colAccounts.Filter = Array("user")
For Each objUser In colAccounts
Wscript.Echo objUser.Name objUserFlags = objUser.Get("UserFlags")
objPasswordExpirationFlag = objUserFlags OR ADS_UF_DONT_EXPIRE_PASSWD
objUser.Put "userFlags", objPasswordExpirationFlag
objUser.SetInfo
Next

Sunday, October 23, 2005

Set AD user password to non-expiry

using System.DirectoryServices;using ActiveDs;
//Add reference to COM Active DS TypeLib

static void DontExpirePassword(DirectoryEntry User)
{
int val;
const int ADS_UF_DONT_EXPIRE_PASSWD =0x10000;
val = (int) User.Properties["userAccountControl"].Value;
User.Properties["userAccountControl"].Value = val ADS_UF_DONT_EXPIRE_PASSWD;
User.CommitChanges();
}

Wednesday, September 28, 2005

Shutting down remote PCs

Dim oFSO, oTS, sClient, oWindows, oLocator, oConnection, oSys
Dim sUser, sPassword
'set remote credentials
sUser = "Administrator"sPassword = "password"
'open list of client names
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oTS = oFSO.OpenTextFile("C:\clients.txt")
Do Until oTS.AtEndOfStream
'get next client name
sClient = oTS.ReadLine
'get WMI locator
Set oLocator = CreateObject("WbemScripting.SWbemLocator")
'Connect to remote WMI
Set oConnection = oLocator.ConnectServer(sClient, "root\cimv2", sUser, sPassword)
'issue shutdown to OS ' 4 = force logoff ' 5 = force shutdown ' 6 = force rebooot ' 12 = force power off
Set oWindows = oConnection.ExecQuery("Select " & "Name From Win32_OperatingSystem")
For Each oSys In oWindows
oSys.Win32ShutDown(5)
Next
Loop
'close the text fileoTS.CloseWScript.Echo "All done!"

You should know a couple of things about this script. First, you need to have a text file named C:\Clients.txt on the machine where the script runs. That file should contain the list of client names you want to shut down. Instead of using a text file, you can modify this script to use ADSI, enabling it to query computer names from Active Directory or an NT domain. However, as you probably don’t want to run this script against every computer on your network (shutting down all of your servers might be bad), the text file provides you with complete control over which computers the script will affect.

Wednesday, August 24, 2005

Setting a User Account Expiration

Type type = usr.NativeObject.GetType();
Object adsNative = usr.NativeObject;
type.InvokeMember("AccountExpirationDate", BindingFlags.SetProperty, null, adsNative, new object[]{"21/01/2006"});
usr.CommitChanges();

Tuesday, August 16, 2005

Getting PHP to work with MySQL on IIS/W2k3

Make sure that the PHP directory is in the System PATH variable. Only version 5.1.5 works with 64bit W2K3.

Monday, July 25, 2005

Getting a .Net Compact Framework Form to cover full screen

The form must not have a menu or a control box. Set the WindowState to Maximized in the form load event. That's it.

Wednesday, July 13, 2005

Getting PHP MySQL to work on Fedora Core 3

The Php MySQl module is not installed by default on Fedora Core 3. Install the following RPM:

ftp://rpmfind.net/linux/fedora/core/updates/3/i386/php-mysql-4.3.11-2.6.i386.rpm

Importing GPG public keys on Fedora Core 3

# rpm --import /usr/share/doc/fedora-release-3/RPM-GPG-KEY*

Wednesday, June 8, 2005

VBScript to delete all files older than 2 months

const fldname = "c:\test"
set fso = createobject("scripting.filesystemobject")
set fldr = fso.getfolder(fldname)
set dttoday = date
set dt2monthsago = dateadd("m", -2, dttoday)

recurse fldr

sub recurse( byref fldr)
dim subfolders,files,folder,file
set subfolders = fldr.subfolders
set files = fldr.files
wscript.echo fldr.path

for each file in files
if file.datelastmodified < dt2monthsago then
wscript.echo "Deleting " & file.name & " last modified: " & file.datelastmodified
on error resume next
file.delete
end if

next
for each folder in subfolders
recurse folder
next
set subfolders = nothing
set files = nothing
end sub

Sunday, June 5, 2005

Getting PHP to work on IIS6 on Win2K3

Copy c:\php\php.ini-distrib to c:\windows\php.ini
In IIS, under 'Home Directory', click on the 'Configuration', 'Application Mappings' tab.
Click 'Add' and enter C:\php\php5isapi.dll for .php extensionGo back to IIS.
Add and allow the PHP ISAPI Extension to IIS Web Service Extensions: C:\PHP\php5isapi.dll Open IIS Manager
Click on "Web Service Extensions"
Add a new Web service extension...Enter "PHP ISAPI Extension" as the "Extension name" Click the "Add..." button and browse to the php5isapi.dll file in your PHP install directory Check the "Set extension status to Allowed" checkbox and click "OK"

Wednesday, June 1, 2005

Getting the virtual URL of a SharePoint web app script

Request.Url doesn't give you what it says on the browser Url box. You need to use the following:

string scriptUrl = Request.ServerVariables["HTTP_VTI_SCRIPT_NAME"];
 
Jeffrey Ting Jeffrey Ting on Facebook Jeffrey Ting on Spock Jeffrey Ting on Plaxo Jeffrey Ting on Spoke Jeffrey Ting on LinkedIn