Scripts
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb Site ManagementScripts

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old October 29th, 2003, 01:04 PM
btrail btrail is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: Rochester, NY
Posts: 3 btrail User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
NT/W2K/XP script loop variable won't reset

I'm writing a simple script to scan systems on my NT/W2K/XP network for the existence of a particular file and report relative to the file's date.

I want various checks to happen on each loop including one check on the "system" variable %ERRORLEVEL%. What I am finding is that this variable doesn't get reset on each pass

code sample:
FOR /F %%a IN (%1) DO (
IF NOT EXIST "\\%%a\admin$\system32\." ECHO %%a not online
dir "\\%%a\c$\program files\jsconsole\ntcon.bat" | FINDSTR "search string" > nul
IF ERRORLEVEL 0 (
echo %%a has right file
) ELSE (
echo %%a has wrong file or no file at all
)
)

In this case ERRORLEVEL comes into the FOR loop as one value and won't change inside the loop. Is there a way to refresh the value inside the loop, a sort of local variable?

Any comments...

Brad

Reply With Quote
  #2  
Old August 26th, 2004, 06:18 PM
btrail.skinna.n btrail.skinna.n is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 2 btrail.skinna.n User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
free hip hop downloads and battle forums

sedukshun records check out this site for the best new hip hop downloads around btrail and skinna from the sedukshun crew are working on there new album due for release early 2005 check em out sedukshun records

Reply With Quote
  #3  
Old September 27th, 2004, 02:01 PM
DevCon4 DevCon4 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Location: Northern Thailand
Posts: 74 DevCon4 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 55 m 51 sec
Reputation Power: 5
I don't see it looping because you only have %1 in the ().

Maybe your problem is that "if errorlevel 0" means ZERO OR MORE so it's always true.

Maybe you need something like this:

if errorlevel 1 do this && goto ENDchk
if errorlevel 0 do that && goto ENDchk
:ENDchk

DC4

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb Site ManagementScripts > NT/W2K/XP script loop variable won't reset


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway