20
May/10
0

Change Outlook 2003 Free Busy Update Information

Here’s a small batch that changes Outlook Free Busy Information in your local Registry.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
@ECHO OFF
 
SET FBPublishRange=%1
SET FBUpdateSecs=%2
 
IF NOT DEFINED FBPublishRange (
  SET FBPublishRange=6
  )
IF %FBPublishRange% LSS 1 (
  GOTO :HELP)
IF %FBPublishRange% GTR 12 (
  GOTO :HELP)
 
IF NOT DEFINED FBUpdateSecs (
  SET FBUpdateSecs=1800
  )
IF %FBUpdateSecs% LSS 1800 (
  GOTO :HELP)
IF %FBUpdateSecs% GTR 7200 (
  GOTO :HELP)
 
ECHO Updating Outlook Free Busy Options  
ECHO  Updating FBPublishRange using value %FBPublishRange%
reg add HKCU\Software\Microsoft\Office\11.0\Outlook\Preferences /t REG_DWORD /v FBPublishRange /d %FBPublishRange% /f>NUL
ECHO  Updating FBUpdateSecs using value %FBUpdateSecs%
reg add HKCU\Software\Microsoft\Office\11.0\Outlook\Preferences /t REG_DWORD /v FBUpdateSecs /d %FBUpdateSecs% /f>NUL
IF %ERRORLEVEL% EQU 0 (
	ECHO Update Completed Successfully
  GOTO :EOF
	) ELSE (
	ECHO There was an error updating Outlook Free Busy Options. Return Value: %ERRORLEVEL%
	GOTO :EOF
	)
:HELP
ECHO.
ECHO Invalid Arguments Found
ECHO ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
ECHO.
ECHO Allows 2 optional arguments: [FBPublishRange] and [FBUpdateSecs]
ECHO.
ECHO Argument 1 specifies the number of months to publish Free/Busy information
ECHO   Valid values for argument 1 (FBPublishRange): 1 to 12
ECHO.
ECHO Argument 2 specifies the update interval to publish Free/Busy information
ECHO   Valid values for argument 2 (FBUpdateSecs): 1800 to 7200
ECHO.
ECHO Examples:
ECHO.
ECHO "UpdateOutlookFreeBusy.cmd" Uses default values 
ECHO   -FBPublishRange = 6, FBUpdateSecs = 1800
ECHO.
ECHO "UpdateOutlookFreeBusy.cmd 9"
ECHO   -FBPublishRange = 9, FBUpdateSecs = 1800
ECHO.
ECHO "UpdateOutlookFreeBusy.cmd 9 2400"
ECHO   -FBPublishRange = 9, FBUpdateSecs = 2400
GOTO :EOF
 
:EOF
Print This Post
(No Ratings Yet)
Loading ... Loading ...
204 views
18
Dec/09
2

Create a Share Remotely using the WMI Command-Line Tool

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

Print This Post
(2 votes, average: 4.50 out of 5)
Loading ... Loading ...
1,123 views
4
Nov/09
2

Recursively delete Subdirectories from a command prompt

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

Print This Post
(No Ratings Yet)
Loading ... Loading ...
1,952 views
12
Aug/09
0

Terminate and disable RDP Sessions for a specific time frame

Here’s a small batch that terminates open RDP sessions on a Windows 2003 Server and disables RDP logons during the time the script runs.
Don’t ask, I recently had a funny case where I needed to schedule this to run daily. (I used the Windows Task Scheduler)

?Download PauseRDP.cmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
IF NOT DEFINED DEBUG @ECHO OFF
SETLOCAL
SET strMessage="Some user notification text"
::Notify Users
MSG * /SERVER:%COMPUTERNAME% /TIME:900 %strMessage%
::Disable Logon
CHANGE LOGON /DISABLE
::Wait 15 Minutes
SLEEP 900
::Teach them the hard way
FOR /L %%i in (1,1,10) DO (
	LOGOFF %%i /SERVER:%COMPUTERNAME%
	)
 
::Do some important stuff here
 
::Enable Logons again
CHANGE LOGON /ENABLE
Print This Post
(3 votes, average: 3.67 out of 5)
Loading ... Loading ...
456 views
Tagged as:
10
Aug/09
0

Multiping Machines with a Batch

Here’s a quick and easy way to ping multiple computers using a batch file (actually 2 batch files).

You could actually use a one liner, but this one is a bit more fancy and much quicker as it runs the pings in parallel.

Copy paste the code below into the corresponting file (both must be in the same directory) and run whatsup.cmd assets.txt

File: whatsup.cmd

?Download whatsup.cmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
if not defined debug @echo OFF
 
set ok=0
set nok=0
set count=0
cls
echo.
echo Pinging all adapters
echo.
set inputfile=%1
for /f %%i in (%inputfile%) do (
	set /A count=count+1
 	start /B %~dp0\whatsuploop.cmd "%%i"
)
 
echo %count% Pings running
 
:wait_to_complete
	sleep 3
	set missing=0
	for /f %%i in (%inputfile%) do (
		if exist %temp%\%%i.ok set /A missing=missing+1
		if exist %temp%\%%i.false set /A missing=missing+1
	)
	echo %missing% Pings complete of %count%
if not %missing%==%count% goto :wait_to_complete
 
if exist %temp%\WHATSDOWN.txt del /Q TMP\WHATSDOWN.txt
if exist %temp%\WHATSUP.txt del /Q TMP\WHATSUP.txt
echo.
echo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
echo Details:
echo.
for /f %%i in (%inputfile%) do (
	if exist %temp%\%%i.ok set /A ok=ok+1&&echo [RUNNING] %%i>>%temp%\WHATSUP.txt
	if exist %temp%\%%i.ok del %temp%\%%i.ok
	if exist %temp%\%%i.false set /A nok=nok+1&&echo [STOPPED] %%i>>%temp%\WHATSDOWN.txt
	if exist %temp%\%%i.false del %temp%\%%i.false
)
if exist %temp%\WHATSDOWN.txt type %temp%\WHATSDOWN.txt
if exist %temp%\WHATSUP.txt type %temp%\WHATSUP.txt
if exist %temp%\WHATSDOWN.txt type %temp%\WHATSDOWN.txt>WHATSDOWN.txt
if exist %temp%\WHATSUP.txt type %temp%\WHATSUP.txt>WHATSUP.txt
if exist %temp%\WHATSDOWN.txt del /Q %temp%\WHATSDOWN.txt
if exist %temp%\WHATSUP.txt del /Q %temp%\WHATSUP.txt
echo.
echo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
echo Summary:
echo.
echo [RUNNING] %ok%
echo [STOPPED] %nok%
echo.
echo ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
echo.
:EOF

File: whatsuploop.cmd

1
2
3
4
5
6
7
8
@echo off
ping -n 1 -l 8 -f %1>NUL
if %errorlevel%==0 (
   echo.>%temp%\%1.ok
) else (
   echo.>%temp%\%1.false
)
exit

File: assets.txt

?Download assets.txt
1
2
3
4
COMPUTER1
COMPUTER2
COMPUTER3
etc..
Print This Post
(4 votes, average: 5.00 out of 5)
Loading ... Loading ...
321 views