MSFN Forum: Oh soooo close.... - MSFN Forum

Jump to content



Unattended CD/DVD Guide Homepage · MSFN Forum Rules

Welcome to the Applications Installs forum. Make sure you read the forum rules before you start posting.

Links/Requests to warez and/or any illegal material (porn, cracks, serials, etc..) will not be tolerated. Discussion of circumventing WGA/activation/timebombs/keygens or any other illegal activity will also not be tolerated.

We try our best to keep this forum clean of illegal content. If you see any illegal activity use the "report" button you find in every post to report the specific post to the moderators. If you ignore any of the rules you will be banned without notice.

Read Forum Rules
Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Oh soooo close.... -Worlds simplest deployement tool- Rate Topic: -----

#1 User is offline   robotnik 

  • Newbie
  • Group: Members
  • Posts: 19
  • Joined: 08-September 08

Posted 30 December 2008 - 01:16 PM

Hey all,
I am developing a very simple deployment solution. It works well but I'm having some trouble with the return/error codes. When I put a fictitious target computer name in tst.txt, it will return either 0, 53, or 9009 (due to DNS issues on our network). It will return a 0 when it has executed successfully on a real target computer. Here's the source below:

@echo off
echo ********************** >>errors.txt
date /t >>errors.txt
time /t >>errors.txt
echo ---------------------- >>errors.txt
cls
for /f %%a in (tst.txt) DO (
echo Executing on %%a
echo ======================
PSEXEC %%a -c "C:\deployment tool\dummy.bat" dummy.bat
echo %%a reported errorlevel: %errorlevel% >> errors.txt
echo ======================
echo %errorlevel%
pause )



It reads the names of target machines from tst.txt. Dummy.bat is the script that is to be run on the target machines. And error.txt is of course where the errorlevel is supposed to be recorded.

I know that there would be a fair amount of interest in a system like this and hope that we can get this up and running.

Thanks in advance!

This post has been edited by robotnik: 31 December 2008 - 09:57 AM



#2 User is offline   AlBundy33 

  • Member
  • PipPip
  • Group: Members
  • Posts: 217
  • Joined: 02-January 05

Posted 01 January 2009 - 05:42 PM

Try this...
@ECHO OFF
SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION
SET TARGETFILE=%~dp0targets.txt
SET LOG=%~dpn0.log

IF EXIST "!LOG!" DEL /Q "!LOG!"
CALL :TEE %DATE: =0%, %TIME: =0%
CALL :TEE ~~~~~~~~~~~~~~~~~~~~~~~
IF EXIST "%TARGETFILE%" FOR /F "tokens=*" %%C IN ('type "%TARGETFILE%"') DO (
	IF "%%~C"=="" GOTO :EOF
	SET COMMAND=PSEXEC %%~C -c "C:\deployment tool\dummy.bat" dummy.bat
	CALL :TEE running !COMMAND!
	CALL !COMMAND!
	IF NOT !ERRORLEVEL! EQU 0 (
		CALL :TEE %%C reported errorlevel: !ERRORLEVEL!
	)
	CALL :TEE ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
)
PAUSE
GOTO :EOF
	
:TEE
	ECHO %*
	ECHO %* 2>&1 1>>"%LOG%"
	GOTO :EOF


Al

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2011 msfn.org
Privacy Policy