22 July, 2010 | Category: Script, Windows
To install PowerShell on Windows Server 2008 R2 or Hyper-V Server 2008 R2, following features needs to be installed.
- NetFx2-ServerCore
- NetFx3-ServerCore
- MicrosoftWindowsPowerShell
Because Powershell is built on DotNet framework, DotNet 2.0 and 3.5 has to be installed prior to PowerShell installation.
To install PowerShell from command line, run following from elevated command prompt
DISM.exe /online /enable-feature /featurename:NetFx2-ServerCore DISM.exe /online /enable-feature /featurename:NetFx3-ServerCore DISM.exe /online /enable-feature /featurename:MicrosoftWindowsPowerShell
Or run following command if it’s an 64bit machine
DISM.exe /online /enable-feature /featurename:NetFx2-ServerCore-WOW64
DISM.exe /online /enable-feature /featurename:NetFx3-ServerCore-WOW64
DISM.exe /online /enable-feature /featurename:MicrosoftWindowsPowerShell-WOW64
Tags: Command line, PowerShell
4 July, 2010 | Category: Script, Windows
To enable DotNet 3.5 from command line, run following from elevated command prompt
dism.exe /online /enable-feature /featurename:NetFx3
Tags: Command line, DotNet 3.5
24 April, 2010 | Category: Development
I have a batch script which remove a folder and re-create it. The command that remove a folder is rd /s/q and the command create folder is mkdir. Recently I see something weird happening, everytime when the folder is deleted and re-created, there is error message Access is denied displayed. However, if I rerun the create folder command laer, it always pass successfully.
The explanation on http://support.microsoft.com/?id=159199 seems make sense,
This file is in a state known as pending deletion. This file has been deleted, but there are still handles open to it. NTFS will wait until all handles to this file are closed before updating the index. If an attempt is made to access the file, however, NTFS will deny the attempt. Because the file is listed in the index, but is effectively deleted, you can see the file but you cannot access it.
The workaround here is add a 60 seconds sleep between the folder deletion and folder creation operation.
Tags: Command line, Scripts, Troubleshooting
1 March, 2010 | Category: Development, Tips and Tricks
Getting the current working directory
cd /d %~dp0
Comment: %0 is the name of the batch file. ~dp gives you the drive and path.
Tags: Batch Scripts, Command line, Tips
17 February, 2010 | Category: Tips and Tricks
Control panel applets (.CPL) is a shortcut to launch administrator tools quickly.
These are some that used frequently after new OS is setup.
- intl.cpl – Regional and Language Options
- timedate.cpl – Date and Time Properties
- inetcpl.cpl – Internet Properties
- ncpa.cpl – Network Connections
- powercfg.cpl – Power Options Properties
Tags: Command line
10 January, 2010 | Category: Script, Tips and Tricks
powercfg.exe is a windows built in tool to config power management. powercfg.exe is a command line utility, it’s easy to integrate powercfg.exe into scripts.
Turn hibernation off
powercfg -hibernate OFF
Set the power configuration to High Performance
powercfg -setactive 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c
Set the absentia power scheme (the scheme used when no one is logged in)
powercfg.exe -setabsentia 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c
Tags: Batch Scripts, Command line, Windows How to
9 January, 2010 | Category: Script, Tips and Tricks
Enabling the built-in administrator account:
net user administrator /active:yes
Disabling the built-in administrator account:
net user administrator /active:no
Note: Must use an elevated command prompt for this command to work.
Tags: Batch Scripts, Command line, Windows Vista
5 January, 2010 | Category: Script, Tips and Tricks
Shut down
shutdown /s /t 0
Reboot
shutdown /r /t 0
Tags: Batch Scripts, Command line
5 January, 2010 | Category: Tips and Tricks
Domain joined
netdom.exe renamecomputer %computername% /NewName:<new name> /userd:domain\user /passwordd:*
Non-Domain joined
wmic.exe computersystem where name="%computername%" rename name="<new name>"
Tags: Batch Scripts, Command line, Tips
5 January, 2010 | Category: Script, Tips and Tricks
Bring up the Regional and Language Settings dialog box
control intl.cpl
Tags: Batch Scripts, Command line