Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
Find username in txt and goto end
Name: joe smith Date: August 21, 2003 at 11:51:53 Pacific OS: Win2k Pro CPU/Ram: 933/256
Comment:
I need to check a textfile on a server from a logon script for %username% and if it exist I want to goto the end of script.
I have tried with the find command, but not sure what to do after I tell it to find the username.
This is a line I tried, but not sure how to tell it to goto end if it finds the string:
Find /I "%USERNAME%" \\server\shares\sample.txt
I tried to do: If errorlevel 0 goto End, but not working. I am pretty much a rookie at this and don't know how to use variables much. Any help would be greatly appreciated.
Name: lode Date: August 21, 2003 at 12:11:23 Pacific
Reply:
I think you need to drop FIND and use IF EXIST instead, for example:
IF EXIST %username% GOTO END GOTO SKIP :SKIP REM the part of script to skip GOTO END :END REM goes here if %username% exists REM otherwise goes through SKIP
The GOTO after IF EXIST will skip right to END if true.
You may also want to put COMMAND/F/C in front of IF EXIST to pass any errors:
0
Response Number 2
Name: joe smith Date: August 21, 2003 at 13:55:26 Pacific
Reply:
Hey, thanks for the response. This is what I tried, but it doesn't goto end. It just keeps running. if exist %username% \\server\shares\sample.txt goto End
Thanks for any help.
0
Response Number 3
Name: lode Date: August 22, 2003 at 18:56:25 Pacific
Reply:
Well, I'm not sure, but I think what you should try it to pipe the if exist from the find command like this:
Find /I "%USERNAME%" [path] ¦ If Exist %USERNAME% Goto End :End
The pipe ¦ symbol takes what was obtained from the first command, and passes it to the second command. That's the theory, but I'm not too sure if it would work. Some commands don't work when piped.
Summary: NT systems have the %OS% variable set by default to 'Windows_NT', and non-NT systems don't. So, if you just want to act depending if the OS is NT (Win NT4,2000,XP) or non-NT (Win9x, Dos 6.22), this wi...
Summary: I just finished putting the following DOS batch program together (with some help from SECRET_DOOM on this site); line numbers are only here for the discussion that follows): 1 @echo off 2 vol D: |...
Summary: trying to use ss.exe file --- it grabs end user input from bat file what this "Format" is trying to do is a) pick a valid drive b) select if system files should be copied c) select if /q (quick) or /u...