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';
Saturday, August 5, 2006
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.
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.
Labels:
Code
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
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
Labels:
Code
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();
}
//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();
}
Labels:
Code
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.
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.
Labels:
Code
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();
Object adsNative = usr.NativeObject;
type.InvokeMember("AccountExpirationDate", BindingFlags.SetProperty, null, adsNative, new object[]{"21/01/2006"});
usr.CommitChanges();
Labels:
Code
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.
Labels:
Code
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.
Labels:
Code
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
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*
Labels:
Code
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
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
Labels:
Code
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"
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"
Labels:
Code
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"];
string scriptUrl = Request.ServerVariables["HTTP_VTI_SCRIPT_NAME"];
Labels:
Code
Subscribe to:
Posts (Atom)


