Hey all,
I have written a batch file (to work with Batch Blitz 3.0) in which I need to check about 15,000 systems company-wide for the presence of a particular application.
Batch Blitz is simply a program which allows you to write generic BAT files using a variable for the host list, and up to 3 variables for general use, so that a single BAT file can be re-used with different arguments on multiple remote systems. It is simply a GUI interface to the command prompt, which runs BAT files by running them from a command prompt, and acts just as it would if you ran a single batch file from the command prompt itself. The only difference is that once a pass of the BAT file completes, it starts the process all over again for the next host.
It works well on machines on which my NT credentials have administrative rights. However, if I do not have admin rights, it causes Batch Blitz to hang, and the only way to resume scanning is to open the task manager and kill the NET.EXE process.
Currently, I have a routine in the BAT file using the LOCAL.EXE command from the Resource Kit which shows the group members of a remote machine. This allows me to check the local 'Administrators' group on the remote machine. This is the batch file I've written:
Note: %1 is the variable for the HOST name or IP
---------------------------------------------------------
@echo on
path=%path%;"c:\program files\resource kit"
ping %1 -n 1
goto answer%ERRORLEVEL%
:answer0
goto chk4sten
:answer1
echo Ping test FAILED on %1!!!
goto end
:chk4sten
c:
local administrators \\%1
if not errorlevel 1 goto end
net use r: \\%1\c$ /p:no
if not exist "r:\radiology\isite.bat" goto end
cd\machineswithprogram
echo %1 >> machineips.txt
goto end
:end
c:
cd\
net use r: /d /y
-------------------------------------------------
If I don't have rights, it will usually give me an "access denied" error. Since the errorlevel for a successful check is 1, an access denied will result in using the GOTO END statement.
The problem is this....for some reasons, some machines on the network will return an errorlevel of 1 (success), but my name/group is not listed in the administrators local group. This results in the command asking me for new credentials. At this time, I have to open the task manager and kill the NET.EXE process.
So, here's my question.
Is there a way I can check a remote machine from a command prompt (within a batch file) to make sure that I have administrative priveleges? As I stated, this is going to be run on over 15,000 machines every month, and I can't sit by the computer and watch it for hangups.
By the way, I'm running Windows XP Pro on my system, and (unfortunately) I'm using the Windows 2000 Server Resource Kit.
Anyone? Help?
Thanks in advance!!
- Mark
I have written a batch file (to work with Batch Blitz 3.0) in which I need to check about 15,000 systems company-wide for the presence of a particular application.
Batch Blitz is simply a program which allows you to write generic BAT files using a variable for the host list, and up to 3 variables for general use, so that a single BAT file can be re-used with different arguments on multiple remote systems. It is simply a GUI interface to the command prompt, which runs BAT files by running them from a command prompt, and acts just as it would if you ran a single batch file from the command prompt itself. The only difference is that once a pass of the BAT file completes, it starts the process all over again for the next host.
It works well on machines on which my NT credentials have administrative rights. However, if I do not have admin rights, it causes Batch Blitz to hang, and the only way to resume scanning is to open the task manager and kill the NET.EXE process.
Currently, I have a routine in the BAT file using the LOCAL.EXE command from the Resource Kit which shows the group members of a remote machine. This allows me to check the local 'Administrators' group on the remote machine. This is the batch file I've written:
Note: %1 is the variable for the HOST name or IP
---------------------------------------------------------
@echo on
path=%path%;"c:\program files\resource kit"
ping %1 -n 1
goto answer%ERRORLEVEL%
:answer0
goto chk4sten
:answer1
echo Ping test FAILED on %1!!!
goto end
:chk4sten
c:
local administrators \\%1
if not errorlevel 1 goto end
net use r: \\%1\c$ /p:no
if not exist "r:\radiology\isite.bat" goto end
cd\machineswithprogram
echo %1 >> machineips.txt
goto end
:end
c:
cd\
net use r: /d /y
-------------------------------------------------
If I don't have rights, it will usually give me an "access denied" error. Since the errorlevel for a successful check is 1, an access denied will result in using the GOTO END statement.
The problem is this....for some reasons, some machines on the network will return an errorlevel of 1 (success), but my name/group is not listed in the administrators local group. This results in the command asking me for new credentials. At this time, I have to open the task manager and kill the NET.EXE process.
So, here's my question.
Is there a way I can check a remote machine from a command prompt (within a batch file) to make sure that I have administrative priveleges? As I stated, this is going to be run on over 15,000 machines every month, and I can't sit by the computer and watch it for hangups.
By the way, I'm running Windows XP Pro on my system, and (unfortunately) I'm using the Windows 2000 Server Resource Kit.
Anyone? Help?
Thanks in advance!!
- Mark