Active Topics Active Topics  Display List of Forum Members Memberlist  Invert Forum Background Colours Invert Colours  Search The Forum Search  Help Help  Register Register  Login Login
Sponsored by Beatnik Games
Hardware / Software Bits & Bobs
 |SFH| Sent From Hell :: Community Forums : Hardware / Software Bits & Bobs
Subject Topic: Some of the bollox I write at work... (Topic Closed Topic Closed) Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
Nhumrod
Site Admin
Site Admin
Avatar
Clan Leader & GM

Joined: 09 September 2002
Location: Scotland
Posts: 13897
Posted: 23 August 2006 at 1:49pm | IP Logged  

Thought osme people may be marginally interested in some of the scripty things I write at work. Wrote this one this week:

@echo off

REM Desc: Discover NTP Offset to DC and output to file
REM Vers: 1.1
REM Date: 17/08/2006
REM Auth: Alex Galbraith
REM Notes: Does not require any input, simply double click batch file. Will create dc.txt and offset.txt
REM Updates: 17/08/2006 - Added Set DomName=!DomName:*REG_SZ =!   and   Set DomName=!DomName:*SZ =!
REM Updates: 21/08/2006 - Added "Get NTPServer Name" and "Get NTP Type" sections
REM Updates: 22/08/2006 - Replaced "Get DC Name" with net time commands
REM Updates: 23/08/2006 - Created stand alone version which downloads results to \\tsclient\d\audits\ntp

SetLocal EnableDelayedExpansion

%systemdrive%
cd %systemdrive%\TEMP\

REM ****************** Get Domain Name ******************
echo ****************** Get Domain Name

reg query HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\Tcpip\Parameters /v Domain> %systemdrive%\TEMP\domain.txt
For /F "tokens=* delims=" %%A in (%systemdrive%\TEMP\domain.txt) Do (
Set DomName=%%A
Set DomName=!DomName:*REG_SZ =!
Set DomName=!DomName:*SZ =!
Set DomName=!DomName: =!
echo !DomName!> %systemdrive%\TEMP\domain.txt)


REM ****************** Get DC Name ******************
echo ****************** Get DC Name
net time>%systemdrive%\TEMP\dc.txt

For /F "tokens=1-2 delims=/" %%a in (dc.txt) Do (
Set DCName=%%a
Set DCName=!DCName:*\\=!
Set DCName=!DCName:*lly.=!
Set DCName=!DCName:is =!
echo !DCName!>>%systemdrive%\TEMP\tmp.txt)


del dc.txt & ren tmp.txt dc.txt
For /F "tokens=1-2 delims=." %%a in (dc.txt) Do (
Set DCName=%%a
echo !DCName!>>%systemdrive%\TEMP\tmp.txt)

For /f %%a in (tmp.txt) do (
Set DCName=%%a
Set DCName=!DCName: =!
echo !DCName!>%systemdrive%\TEMP\tmp.txt
goto :1
)

:1
del dc.txt & ren tmp.txt dc.txt


REM ****************** Get NTPServer Name ******************
echo ****************** Get NTPServer Name
reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Parameters" /v NtpServer> %systemdrive%\TEMP\ntpserver.txt
For /F "tokens=* delims=" %%A in (ntpserver.txt) Do (
Set strNTPServer=%%A
Set strNTPServer=!strNTPServer:*REG_SZ =!
Set strNTPServer=!strNTPServer:*SZ =!
Set strNTPServer=!strNTPServer:,0x1=!
echo !strNTPServer!>%systemdrive%\TEMP\ntpserver.txt)


REM ****************** Get NTP Type ******************
echo ****************** Get NTP Type
reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Parameters" /v Type> %systemdrive%\TEMP\ntptype.txt
For /F "tokens=* delims=" %%A in (ntptype.txt) Do (
Set strNTPType=%%A
Set strNTPType=!strNTPType:*REG_SZ =!
Set strNTPType=!strNTPType:*SZ =!
Set strNTPType=!strNTPType:,0x1=!
echo !strNTPType!>%systemdrive%\TEMP\ntptype.txt)


REM ****************** Gather NTP Offset ******************
echo ****************** Gather NTP Offset
w32tm /stripchart /computer:!DCName! /samples:1 /dataonly> %systemdrive%\TEMP\result.txt

 

REM ****************** Cleanup Results ******************
echo ****************** Cleanup Results
For /F "tokens=* delims=" %%A in (result.txt) Do (
Set OffsetTxt=%%A
Set OffsetTxt=!OffsetTxt:* o:=!
Set OffsetTxt=!OffsetTxt:*, =!
Set OffsetTxt=!OffsetTxt:s=!
Set OffsetTxt=!OffsetTxt: =!
echo !OffsetTxt!>>tmp.txt)
del result.txt & ren tmp.txt result.txt

for /f "tokens=*" %%L in (result.txt) do call :sub2 %%L
del %systemdrive%\TEMP\result.txt
copy %systemdrive%\TEMP\tempfile.txt %systemdrive%\TEMP\offset.txt>nul
del %systemdrive%\TEMP\tempfile.txt


REM ****************** Combine data from files ***************************
echo ****************** Combine data from files

hostname > %systemdrive%\TEMP\hostname.txt
For /F "tokens=* delims=" %%A in (hostname.txt) Do (
Set strHostName=%%A
)

For /F "tokens=* delims=" %%A in (offset.txt) Do (
Set strOffset=%%A
)

For /F "tokens=* delims=" %%A in (dc.txt) Do (
Set strDC=%%A
)

For /F "tokens=* delims=" %%A in (domain.txt) Do (
Set strDomain=%%A
)

For /F "tokens=* delims=" %%A in (ntpserver.txt) Do (
Set strNTPServer1=%%A
)

For /F "tokens=* delims=" %%A in (ntptype.txt) Do (
Set strNTPType1=%%A
)

echo !strHostName!,!strOffset!,!strDC!,!strDomain!,!strNTPServer1!,!strNTPType1!>%systemdrive%\TEMP\fullinfo.txt


REM ****************** Download file to local machine *****************

copy %systemdrive%\TEMP\fullinfo.txt \\tsclient\d\audits\NTP\!strHostName!.txt /y

REM ****************** Cleanup temp files **************************
echo ****************** Cleanup temp files
del %systemdrive%\TEMP\dc.txt
del %systemdrive%\TEMP\domain.txt
del %systemdrive%\TEMP\offset.txt
del %systemdrive%\TEMP\hostname.txt
del %systemdrive%\TEMP\ntpserver.txt
del %systemdrive%\TEMP\ntptype.txt
del %systemdrive%\TEMP\fullinfo.txt
pause
goto :eof

:sub2
set /a currNUM+=1
if %currNUM%==4 echo %* >> %systemdrive%\TEMP\tempfile.txt
goto :eof

:eof
pause



__________________
There is no IRL, there's just AFK.
Back to Top View Nhumrod's Profile Search for other posts by Nhumrod Visit Nhumrod's Homepage Send Private Message Add to Buddy List
 
greg
Honourary Member
Honourary Member


Joined: 20 August 2004
Location: United Kingdom
Posts: 2865
Posted: 23 August 2006 at 2:10pm | IP Logged  

Surely the only thing anyone can say to that is:





GEEK

__________________
"You're not drunk if you can lie on the floor without holding on"
Back to Top View greg's Profile Search for other posts by greg Send Private Message Add to Buddy List
 
Richie
Moderatus
Moderatus
Avatar
Moof!

Joined: 09 September 2002
Location: United Kingdom
Posts: 1643
Posted: 23 August 2006 at 2:16pm | IP Logged  

nope no one is interested, and i agree with Greg - GEEK!

i could also bore you to death with stuff from work, but i shall forgoe that horror, suffice to say, you would not be impressed or the least bit interested



__________________
MOOPH!
Back to Top View Richie's Profile Search for other posts by Richie Send Private Message Add to Buddy List
 
Grizzler
Site Admin
Site Admin

Janitor

Joined: 13 Febuary 2003
Location: Norway
Posts: 5192
Posted: 23 August 2006 at 2:25pm | IP Logged  

Nope, dont care, unless you have used the number 4,8,15,16,23,42 somewhere in there :0

__________________

Back to Top View Grizzler's Profile Search for other posts by Grizzler Send Private Message Add to Buddy List
 
Mash-Tin_UK
Clan Member
Clan Member
Avatar

Joined: 21 September 2005
Location: United Kingdom
Posts: 1936
Posted: 23 August 2006 at 2:29pm | IP Logged  

GEEKatr0n. although D's pretty clever  he wooped our asses in trivia

__________________

Your tears fuel me     -      E .� ` ' / �. F
Back to Top View Mash-Tin_UK's Profile Search for other posts by Mash-Tin_UK Send Private Message Add to Buddy List
 
Nhumrod
Site Admin
Site Admin
Avatar
Clan Leader & GM

Joined: 09 September 2002
Location: Scotland
Posts: 13897
Posted: 23 August 2006 at 3:08pm | IP Logged  

you know it baby - i am the trivia master!

I believe when I left (on 81 points) the next nearest contender was Greg, with 19?



__________________
There is no IRL, there's just AFK.
Back to Top View Nhumrod's Profile Search for other posts by Nhumrod Visit Nhumrod's Homepage Send Private Message Add to Buddy List
 
Captain_Oompa
Honourary Member
Honourary Member
Avatar

Joined: 29 March 2005
Location: United Kingdom
Posts: 1554
Posted: 23 August 2006 at 3:14pm | IP Logged  

hehe well done brains...



__________________

Back to Top View Captain_Oompa's Profile Search for other posts by Captain_Oompa Send Private Message Add to Buddy List
 
greg
Honourary Member
Honourary Member


Joined: 20 August 2004
Location: United Kingdom
Posts: 2865
Posted: 23 August 2006 at 3:15pm | IP Logged  

well at least i was nearest, f**kers.

__________________
"You're not drunk if you can lie on the floor without holding on"
Back to Top View greg's Profile Search for other posts by greg Send Private Message Add to Buddy List
 
Mash-Tin_UK
Clan Member
Clan Member
Avatar

Joined: 21 September 2005
Location: United Kingdom
Posts: 1936
Posted: 23 August 2006 at 3:43pm | IP Logged  

hhaa tbh Greg shud of had more, as u spelt alot wrong and was slowe than greg, yet you still managed to get the points

__________________

Your tears fuel me     -      E .� ` ' / �. F
Back to Top View Mash-Tin_UK's Profile Search for other posts by Mash-Tin_UK Send Private Message Add to Buddy List
 
Tefflon
Clan Member
Clan Member
Avatar

Joined: 10 August 2005
Location: Germany
Posts: 607
Posted: 23 August 2006 at 4:01pm | IP Logged  

+ = D ?

__________________
CoD4,CoDWaW,NBA2K9,...

Back to Top View Tefflon's Profile Search for other posts by Tefflon Send Private Message Add to Buddy List
 
Grizzler
Site Admin
Site Admin

Janitor

Joined: 13 Febuary 2003
Location: Norway
Posts: 5192
Posted: 23 August 2006 at 4:08pm | IP Logged  

Demon has 80 points, greg has 35.

Yeah, I can put on so you have to spell it correctly next time

__________________

Back to Top View Grizzler's Profile Search for other posts by Grizzler Send Private Message Add to Buddy List
 
Nhumrod
Site Admin
Site Admin
Avatar
Clan Leader & GM

Joined: 09 September 2002
Location: Scotland
Posts: 13897
Posted: 23 August 2006 at 4:35pm | IP Logged  

fine by me...

__________________
There is no IRL, there's just AFK.
Back to Top View Nhumrod's Profile Search for other posts by Nhumrod Visit Nhumrod's Homepage Send Private Message Add to Buddy List
 
Mojo Jojo
Moderatus
Moderatus
Avatar
Sir Sleeps Alot

Joined: 14 November 2002
Location: Scotland
Posts: 1916
Posted: 23 August 2006 at 5:59pm | IP Logged  

I would cut and paste some of my code, but I'm sure that would violate my NDA or something.

__________________
The two most common elements in the universe are Hydrogen and stupidity.

Back to Top View Mojo Jojo's Profile Search for other posts by Mojo Jojo Send Private Message Add to Buddy List
 
hamble
Honourary Member
Honourary Member
Avatar
Middle Eastern Terrorist

Joined: 03 August 2003
Location: Bahrain
Posts: 1054
Posted: 23 August 2006 at 7:55pm | IP Logged  



You are head computer dork Demon, but I appreciate your networking technical support, so I will not say anymore.

Back to Top View hamble's Profile Search for other posts by hamble Visit hamble's Homepage Send Private Message Add to Buddy List
 
Nhumrod
Site Admin
Site Admin
Avatar
Clan Leader & GM

Joined: 09 September 2002
Location: Scotland
Posts: 13897
Posted: 23 August 2006 at 9:43pm | IP Logged  



__________________
There is no IRL, there's just AFK.
Back to Top View Nhumrod's Profile Search for other posts by Nhumrod Visit Nhumrod's Homepage Send Private Message Add to Buddy List
 
Nhumrod
Site Admin
Site Admin
Avatar
Clan Leader & GM

Joined: 09 September 2002
Location: Scotland
Posts: 13897
Posted: 23 August 2006 at 9:44pm | IP Logged  

btw in case u wanna know what that script does, it pulls down and formats NTP information from the registry - the more complex version also renames the final results to a txt file with the servers name and uploads it all to a central server. The reason I mention it is cos we may be able to do something similar in future with HLTV demos of matches

__________________
There is no IRL, there's just AFK.
Back to Top View Nhumrod's Profile Search for other posts by Nhumrod Visit Nhumrod's Homepage Send Private Message Add to Buddy List
 
Mojo Jojo
Moderatus
Moderatus
Avatar
Sir Sleeps Alot

Joined: 14 November 2002
Location: Scotland
Posts: 1916
Posted: 24 August 2006 at 10:18am | IP Logged  

lol! Did you have to do all that by hand before?

__________________
The two most common elements in the universe are Hydrogen and stupidity.

Back to Top View Mojo Jojo's Profile Search for other posts by Mojo Jojo Send Private Message Add to Buddy List
 
Nhumrod
Site Admin
Site Admin
Avatar
Clan Leader & GM

Joined: 09 September 2002
Location: Scotland
Posts: 13897
Posted: 24 August 2006 at 11:28am | IP Logged  

do what? HLTV demos or NTP audits?

The guys at work used to do all audits by hand until I started there. Ive now written scripts to audit almost anything reqd and upload to central servers. Seems to do the job - I audited over 500 servers in about an hour yesterday.



__________________
There is no IRL, there's just AFK.
Back to Top View Nhumrod's Profile Search for other posts by Nhumrod Visit Nhumrod's Homepage Send Private Message Add to Buddy List
 
|SFH|gama_k
Site Admin
Site Admin

Deputy Clan Leader

Joined: 09 September 2002
Location: United Kingdom
Posts: 744
Posted: 24 August 2006 at 11:34am | IP Logged  

there gona love you when they start laying off people lol
Back to Top View |SFH|gama_k's Profile Search for other posts by |SFH|gama_k Send Private Message Add to Buddy List
 
Nhumrod
Site Admin
Site Admin
Avatar
Clan Leader & GM

Joined: 09 September 2002
Location: Scotland
Posts: 13897
Posted: 24 August 2006 at 11:41am | IP Logged  

heh

__________________
There is no IRL, there's just AFK.
Back to Top View Nhumrod's Profile Search for other posts by Nhumrod Visit Nhumrod's Homepage Send Private Message Add to Buddy List
 

Page of 2
  Post ReplyPost New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 1.1563 seconds.

Sponsored by Beatnik Games