Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hello,
Im having trouble trying to get a file to not run each time my login script runs. What happens is I have an if statement that I want to check the local users system for a File called "Audit.txt" and if has a "1" in it then I want the function to terminate,but if it see's "0" or any other number I want it to run a computer audit program that I have running on the server. So far I have not been able to get the batch to skip over running the audit even if the file has a "1" in it. Can some help with this? I will also attach my loginscript batch file. Also the drives arent mapping could this be cause im not running it as a login script but as a batch file or is the syntax incorrect?
Thanks
@echoff
REM For Windows NT users
if '%OS%'=='Windows_NT4'goto nt4
:nt4
:endREM Setting Environment for 98 users
set os=Windows 98
\\\netlogon\putinenv L/Lecho Hello %USERNAME% welcome to the Network!
echo And you are running the %OS%os\\\netlogon\sleep 2
REM Maps Network Drives
net use Y: \\\users\%USERNAME%
net use P: \\\public
rem net use Y: /delete
rem net use P: /delete
net use Y: \\\users\%USERNAME%
net use P: \\\public:pause
REM Function call to Run Audit Program
cd..c:\audit.txt
IF EXIST c:\audit.txt=='1'goto END
:END
ELSE goto AUDIT
:AUDITrem \\\TrackIT\Audit32.exe
:END
echo 1> c:\Audit.txt
cls\
:EXIT

"IF EXIST" tests for the existence of a file, not whether a file contains a string.
Could you change the logic so you use different filenames for success and failure?
IF EXIST AUDIT.1 GOTO...
ECHO 1 > AUDIT.1
Something like that?

That won't work cause I have a file number that is pushed into "Audit.txt" I need to know the command or how to figure out, for the system to read the local machine and if it sees the number "1" in a file called "Audit.txt" then it skips running a machine audit and goes to the end of the function. But if it sees a number lower or higher then "1" it runs the audit. Im trying to do this so that I can run quartly audits of all my machines. And I will be manually changing the numbers so that machines don't get audited twice or each time a user logs in. But so far I don't have the correct paramaters and it just keeps running the audit program regardless of what exists in the "Audit.txt" file.

Try this:
type c:\audit.txt|find /i "0" > NUL
if not errorlevel 1 goto filecontainszerotype c:\audit.txt|find /i "1" > NUL
if not errorlevel 1 goto filecontainsoneShould work. We are using this syntax to skip the logon script for 5000 PCs.

On the drive map problem from what you pasted you have 3 \'s it should only be two I believe.
And not sure if it is there or not but I think you may also need a space between the : after the drive letter you want and the first \
Perry

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |