microtom.net

tom's windows tech blog

Create a Share Remotely using the WMI Command-Line Tool

2 comments

To manage Windows remotely through the command line interface, you can can use wmic (comes with windows).
Here’s the syntax to create a Windows File Share on a remote machine using a single line of code. With Windows NT some might remember rmtshare.exe which did the same thing, but crashes with more recent versions of Windows.

wmic /node:%REMOTESERVER% share call create “”, “%DESCRIPTION%”,”%MAX CONNECTIONS (LEAVE BLANK FOR UNLTD)%”, “%SHARENAME%”,”" , “%LOCAL PATH TO FOLDER%”, 0

Example:
wmic /node:SERVER1 share call create "", "User Homedrive for microtom","", "microtom$","" , "D:\Shares\Users\microtom", 0

You can find more information on WMIC here:
http://technet.microsoft.com/en-us/library/bb742610.aspx

Written by microtom

December 18th, 2009 at 10:13 am

Disable Legal Notice Text forced by Policy

leave a comment

If you have a Group Policy forcing client computers to display a legal notice text before logging on to Windows, you can set the following key to disable it:

HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\GPExtensions\{827D319E-6EAC-11D2-A4EA-00C04F79F83A}”
New REG_DWORD Value Name: NoMachinePolicy
Data: 1

Alternatively you can copy paste the following line in a command line:

REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\GPExtensions\{827D319E-6EAC-11D2-A4EA-00C04F79F83A}" /v NoMachinePolicy /t REG_DWORD /d 1 /f

Written by microtom

December 8th, 2009 at 5:06 pm

Recursively delete Subdirectories from a command prompt

leave a comment

Some might have noticed that the “del” command will only remove files in a directory and it’s subdirectories.
If you want to delete Subdirectories from a given starting directory (without deleting the root directory itself) you might want to parse through the root folder and delete every directory that is found.

Here’s a small for loop which does the trick.

In this example, all folders within the %temp% folder that start with “OL” would be deleted (Since that is what the “dir” command would return). You might want to modify the path and the wild card to suit your requirements.

In a command line:
for /f %i in ('dir %temp%\OL* /B /D') do rd %i /Q /S
In a batch file:
for /f %%i in ('dir %temp%\OL* /B /D') do rd %%i /Q /S

Written by microtom

November 4th, 2009 at 6:07 pm

Posted in Batch, Script Repository

Tagged with ,

Updating Time on a Windows 2008 Domain Controller from the Internet

leave a comment

Here’s a Registry key that sets your time provider to use time.nist.gov

1
2
3
4
Windows Registry Editor Version 5.00
 
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Parameters]
"ntpserver"="192.43.244.18,0x8"

Written by microtom

October 24th, 2009 at 4:43 pm

Microsoft SQL 2008 Setup: Performance Counter Registry Hive consistency check failed

3 comments

If you experience this error on a non English or MUI version of Windows Server 2008 this Registry entry helped me to resolve the issue. It adjusts the Performance counter registry values as described in Microsoft’s KB 300956 (http://support.microsoft.com/kb/300956).

IMPORTANT: Before importing the key, make sure to Export your current Perflib settings stored here:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Perflib

Download the Registry Key here: Perflib.zip

SQL2008Perflib

Written by microtom

October 24th, 2009 at 3:53 pm