Windows server 2008 Core – How to activate server

Posted by Mark | Posted in Command line, Scripting, Windows 2008 | Posted on 28-07-2009

0

This post will show you way how to activate Windows server 2008 Core.

You can do that with script named slmgr.vbs.

To perform activation type this in command line:

slmgr.vbs -ato

win2008_act

Press Enter and you are done!

Windows server 2003 and Windows XP – How to script file download from FTP server

Posted by Mark | Posted in Scripting, Windows 2003, Windows XP | Posted on 22-07-2009

1

Do you know how to script basicĀ  FTP server connect/copy operations?

I`ll show you that.

Lets assume you want every Friday at 06:00pm to connect to specific FTP server and download all files from it to directory named D:\Scanfiles.

On your Windows server 2003 or Windows XP start notepad and type:

@echo off
echo user username> ftpbat.dat
echo password>> ftpbat.dat
echo prompt>> ftpbat.dat
echo mget *.*>> ftpbat.dat
echo quit>> ftpbat.dat
ftp -n -s:ftpbat.dat FTPserverIP
del ftpbat.dat

notepad

Save file as ftp.bat and place it in D:\Scanfiles folder.

Change this data:

username – your ftp username
password – your ftp password
FTPserverIP – ip address of ftp server to connect

After that create new scheduled task to run ftp.bat file every Friday at 06:00pm .

Cheers! :)

Windows server 2003 and Windows XP – How to shedule disk defragmenting

Posted by Mark | Posted in Scripting, Windows 2003, Windows XP | Posted on 07-07-2009

0

I`ll show you how to create very nice .bat script which will defragment your disks and generate report in log file.

This script was tested on Windows server 2003 or Windows XP machines.

Ok then, lets say you want to defragment C: and D: disks every Monday and Friday starting job at 10:00pm.

Also you want to store log file on C:\Tools folder.

OK, lets open notepad and copy paste this text:

@Ecxo off
Set logfile=C:\Tools\defrag.log
Echo Start %date%,%time% >>%logfile%
Echo *************************** >>%logfile%
Echo Defragmenting C: disk >>%logfile%
Echo. >>%logfile%
defrag.exe c: -f >>%logfile%
Echo *************************** >>%logfile%
Echo Defragmenting D: disk >>%logfile%
Echo. >>%logfile%
defrag.exe d: -f >>%logfile%
Echo *************************** >>%logfile%
Echo Finished %date%,%time% >>%logfile%
Echo *************************** >>%logfile%

Save this file as Defrag.bat and place it to C:\Tools folder

Now open command line and shedule defragmenting by typing:

at 10:00pm /every:M,F C:\Tools\Defrag.bat

defrag

Press “Enter”

And we are finished !

Windows server 2003 and Windows XP – How to add printer via script

Posted by aidas | Posted in Scripting, Windows 2003, Windows XP | Posted on 16-06-2009

0

In this post i`ll show one of many ways how to connect your users to shared printer. For that open notepad in Windows server 2003 or Windows XP and type:

REM Add Printers
RunDll32.EXE printui.dll,PrintUIEntry /in /n \\sever\printername1
RunDll32.EXE printui.dll,PrintUIEntry /in /n \\sever\printername2

REM Set Default Printer
RunDll32.EXE printui.dll,PrintUIEntry /y /n \\server\printername2
EXIT

For example i have two shared printers on server named “Fileserver” and these printers are shared as “HPLJ1″ and “HPLJ2″. Also i want “HPLJ1″ as default printer for all users. I will type :

REM Add Printers
RunDll32.EXE printui.dll,PrintUIEntry /in /n \\Fileserver\HPLJ1
RunDll32.EXE printui.dll,PrintUIEntry /in /n \\Fileserver\HPLH2

REM Set Default Printer
RunDll32.EXE printui.dll,PrintUIEntry /y /n \\Fileserver\HPLJ1
EXIT

Save this file as Addprinter.bat and place it as login script via group policy or you can deploy it to your users in any other way you prefer.

Windows server 2003 – How to check FSMO role holders

Posted by aidas | Posted in Command line, Scripting, Windows 2003 | Posted on 14-06-2009

0

I`ll show you two quick ways to check FSMO roles on Windows 2003 server.

1. open command line and type :

netdom query fsmo

2. copy this code to notepad and save as fsmo.vbs script :

Set objRootDSE = GetObject(”LDAP://rootDSE”)

Set objSchema = GetObject _
(”LDAP://” & objRootDSE.Get(”schemaNamingContext”))
strSchemaMaster = objSchema.Get(”fSMORoleOwner”)
Set objNtds = GetObject(”LDAP://” & strSchemaMaster)
Set objComputer = GetObject(objNtds.Parent)
WScript.Echo “Forest-wide Schema Master FSMO: ” & objComputer.Name

Set objNtds = Nothing
Set objComputer = Nothing

Set objPartitions = GetObject(”LDAP://CN=Partitions,” & _
objRootDSE.Get(”configurationNamingContext”))
strDomainNamingMaster = objPartitions.Get(”fSMORoleOwner”)
Set objNtds = GetObject(”LDAP://” & strDomainNamingMaster)
Set objComputer = GetObject(objNtds.Parent)
WScript.Echo “Forest-wide Domain Naming Master FSMO: ” & objComputer.Name

Set objDomain = GetObject _
(”LDAP://” & objRootDSE.Get(”defaultNamingContext”))
strPdcEmulator = objDomain.Get(”fSMORoleOwner”)
Set objNtds = GetObject(”LDAP://” & strPdcEmulator)
Set objComputer = GetObject(objNtds.Parent)
WScript.Echo “Domain’s PDC Emulator FSMO: ” & objComputer.Name

Set objRidManager = GetObject(”LDAP://CN=RID Manager$,CN=System,” & _
objRootDSE.Get(”defaultNamingContext”))
strRidMaster = objRidManager.Get(”fSMORoleOwner”)
Set objNtds = GetObject(”LDAP://” & strRidMaster)
Set objComputer = GetObject(objNtds.Parent)
WScript.Echo “Domain’s RID Master FSMO: ” & objComputer.Name

Set objInfrastructure = GetObject(”LDAP://CN=Infrastructure,” & _
objRootDSE.Get(”defaultNamingContext”))
strInfrastructureMaster = objInfrastructure.Get(”fSMORoleOwner”)
Set objNtds = GetObject(”LDAP://” & strInfrastructureMaster)
Set objComputer = GetObject(objNtds.Parent)
WScript.Echo “Domain’s Infrastructure Master FSMO: ” & objComputer.Name

Then open command line and type:

cscript fsmo.vbs



Windows server 2003 – How to backup IIS metabase via command line

Posted by aidas | Posted in Command line, Scripting, Windows 2003 | Posted on 11-05-2009

0

This article will explain how to backup IIS metabase using command line. To perform backup open command line on your Windows server 2003 and type:

cscript iisback.vbs /backup /b <backupname>