Hey EE! I'm trying to run a script that will stop NFS services, copy over two files from a network share to the server's local directory and then start the NFS services. All of that sounds really good but as usual, my novice skills are preventing me from being able to complete it.
Here is what I have so far:
if not exist "%LogFile%" goto SkipRename
for %%f in ("%LogFile%") do (
for /f "tokens=1-3 delims=/ " %%a in ("%%~tf") do (set TimeStamp=%%c%%a%%b)
echo Renaming "%LogFile%" to "!NewName!" ...
ren "%LogFile%" "!NewName!"
ECHO File date: %%~tf
This works just fine as does this next part of the script:
for /F "tokens=3 delims=: " %%H in ('sc query "Gateway for NFS" ^| findstr " STATE"') do (
if /I "%%H" EQU "Gateway for NFS" (
net stop "nfsSvc"
But when the script runs, I would like to know if the command was executed successfully. I've tried a couple of different things but it didn't work. I appreciate your help and will post follow-up questions about this script after this one is closed.