I'm trying to get Hostname, Date and Time from remote systems wherein I am not getting the desired results when I execute the server side batch file
Reference: Remote Side Batch File
@echo off
hostname.exe > __t.tmp
set /p host=<__t.tmp
del __t.tmp
set hst=%host%
set dt=%Date%
Set tm = %Time%
set RETURNVALUE= %host%, %Date%, %Time%
ENDLOCAL&SET %~1=%RETURNVALUE%
This is returning all good if I echo the 'ReturnValue'
And Server Side Batch File (iplist.txt is the file containing IPs of remote machine)
@echo off
for /f "tokens=*" %%a in ('type iplist.txt') do (
set line=%%a
echo %line%
wmic /node:%line% process call create "cmd.exe D:\\Scripts\\RCMD_TS.bat RtVal"
echo %RtVal%
)
set %%a=
set %a=
set line=
set rt=
This returning the following:
D:\Scripts>ServerSideExecuteRemoteCommand.bat
ECHO is off.
call - Alias not found.
ECHO is off.
ECHO is off.
call - Alias not found.
ECHO is off.
ECHO is off.
call - Alias not found.
ECHO is off.
ECHO is off.
call - Alias not found.
ECHO is off.
What am I doing wrong here? Also can I get 3 values (Separate Hostname, Date and Time) instead of 1 (Return Value) I tried but it does not happen.