28
Aug/09
0

Create a shortcut via script

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
  'Create Shortcut

    Option Explicit
    Dim objShell, objDesktop, objLink
    Dim strAppPath, strWorkDir, strIconPath
 
    strWorkDir =""
    strAppPath = "\\Servername\share\somefolder\some.exe"
    strIconPath = "%SystemRoot%\system32\SHELL32.dll,158"
 
    Set objShell = CreateObject("WScript.Shell")
    objDesktop = objShell.SpecialFolders("AllUsersDesktop")
    Set objLink = objShell.CreateShortcut(objDesktop & "\MyNewLink.lnk")
 
    objLink.Description = "Shortcut Description"
    objLink.HotKey = "CTRL+SHIFT+O"
    objLink.IconLocation = strIconPath 
    objLink.TargetPath = strAppPath
    objLink.WindowStyle = 3
    objLink.WorkingDirectory = strWorkDir
    objLink.Save
Print This Post
(3 votes, average: 5.00 out of 5)
Loading ... Loading ...
338 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 ...
454 views
Tagged as:
10
Aug/09
0

Get the Directory Size via script

The Script uses the FileSystemObject to retrieve the size of a Directory.
Takes 1 Argument (The Directory Path)

File: GetDirectorySize.js

?View Code JAVASCRIPT
1
2
3
4
5
6
7
8
function main()
{
var fs = WScript.CreateObject("Scripting.FileSystemObject");
var dir = fs.GetFolder(WScript.Arguments(0));
WScript.Echo (dir.Size);
}
 
main();
Print This Post
(3 votes, average: 4.33 out of 5)
Loading ... Loading ...
311 views
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 ...
320 views
7
Aug/09
0

“Must Haves” for Windows Admins

Windows Server 2003 Resource Kit Tools

The Microsoft® Windows® Server 2003 Resource Kit Tools are a set of tools to help administrators streamline management tasks such as troubleshooting operating system issues, managing Active Directory®, configuring networking and security features, and automating application deployment.

Download

Windows Server 2003 Service Pack 1 Support Tools

The Windows Support Tools for Microsoft Windows 2003 are intended for use by Microsoft support personnel and experienced users to assist in diagnosing and resolving computer problems.

Download

Windows Server 2003 Service Pack 2 Administration Tools Pack for x86 editions

The Administration Tools Pack allows administrators to install the Windows Server 2003 SP2 management tools onto a computer running Windows XP Professional or a Windows Server 2003 family operating system to perform remote server management functions.

Download

Windows Server 2003 Administration Tools Pack

The Windows Server 2003 Administration Tools Pack (adminpak.msi) provides server management tools that allow administrators to remotely manage Windows 2000 Servers & Windows Server 2003 family servers. This is the final version (build 3790) of the adminpak.msi file.

Download

Sysinternals Suite

The Sysinternals Troubleshooting Utilities have been rolled up into a single Suite of tools. This file contains the individual troubleshooting tools and help files. It does not contain non-troubleshooting tools like the BSOD Screen Saver or NotMyFault.

Download

Scriptomatic V2

Utility that helps you write WMI scripts for system administration.

Download

Print This Post
(3 votes, average: 4.00 out of 5)
Loading ... Loading ...
219 views