Archive for the ‘Batch Files’ Category

netsh – Amending a Default Gateway on NICs via scripts.

Wednesday, October 31st, 2012

Quick one today.

Wanted to change a servers default gateway in a CMD file. Easiest way to do it is to use NETSH. Its a very powerful tool (All Windows versions after XP) that has many uses from configuring the Windows Firewall to resetting branchcache.

In this instance I wanted to do a simple default Gateway change , so here’s the barebones of it:

(more…)

FQDN of a Windows Server in Batch / CMD scripting….

Monday, April 30th, 2012

Quick one for you (and there’s probably easier ways of doing this)…only took ten minutes to work it out tho.

I needed to get the Fully Qualified Domain Name of a computer on the network into an environment variable in a batch script.

Here’s the code snippet:

@ECHO OFF

FOR /f "tokens=2,* delims= " %%a in ('IPCONFIG ^/ALL ^| FINDSTR "Primary Dns"') do set tempsuffix=%%b
FOR /f "tokens=1,2 delims=:" %%a in ('echo %tempsuffix%') do set dnssuffix=%%b
SET FQDN=%COMPUTERNAME%.%DNSSUFFIX:~1%

ECHO Server FQDN: %FQDN%

Unattended silent install of Microsoft WSE 3.0 (MSI)

Friday, March 2nd, 2012

I’ve been on a project where a number of prerequisites needed scripting and we’re provided in the MSI format.

This is the Microsoft Installer format. There are a number of switches you can use which can streamline an application install. Problem was that the way our installing system operates here, the execution environment runs as the BUILTIN\Administrator, but doesn’t load his profile so its taken some time to find the right combination of switches.

(more…)

Find Read Only Files in Multiple Directories

Wednesday, March 4th, 2009

A quick Bat script that will read input from a txt file with folder locations and identify read only files outputting them to a csv file.

(more…)