How to remotely execute packages on Windows 7 machines. You will need psexec, a computers.txt file (with your machine names), and an automated installation package.
@echo off
title Remote Installation by Eddie Jackson
color 0a
REM EXTERNAL VARIABLES
rem must be an automated package
set appname=Automated.exe
rem credentials to the machine(s)
set UserN=administrator
set PassW=welcome123
rem —————————————————–
Setlocal EnableDelayedExpansion
rem Server file(s) path
set CurDir=%CD%
rem Report name
Set report=Report.txt
rem Enter name of computer text file
Set PCList=computers.txt
REM CREATES DATE AND TIME TIMESTAMP
for /F “tokens=2-4 delims=/- ” %%p in (‘date/T’) do set mdate=%%r%%p%%q
for /F “tokens=1-2 delims=:- ” %%p in (‘time/T’) do set mtime=%%p%%q
Set ReportN=%mdate%_%mtime%_%report%
rem —————————————————–
for /f “tokens=* delims= ” %%a in (%PCList%) do (
echo Loading workstation name…
ping %%a | find “Reply” > nul
if errorlevel 1 (echo !date! !time! %%a, OFFLINE >> “Reports\%ReportN%”
echo %%a not found…
echo %%a>> “Reports\offline_machines.txt”
echo.
echo.
%windir%\system32\ping.exe -n 2 127.0.0.1>nul
) else (
echo !date! !time! %%a, ONLINE >> “Reports\%ReportN%”
rem clear session
del /q \\%%a\c$\windows\system32\remote.vbs
rem create remote.vbs
echo on error resume next>”%CurDir%\remote.vbs”
echo Set objShell = CreateObject^(“Wscript.Shell”^)>>”%CurDir%\remote.vbs”
echo objShell.Run “c:\windows\system32\%appname%”,0,true>>”%CurDir%\remote.vbs”
rem copy files
copy /y “%CurDir%\%appname%” \\%%a\c$\windows\system32
copy /y “%CurDir%\remote.vbs” \\%%a\c$\windows\system32
ping -n 4 127.0.0.1>nul
rem launch remote – REMOVE THE -I TO MAKE SILENT
psexec.exe -d -i \\%%a -u %%a\%UserN% -p %PassW% wscript.exe remote.vbs
ping -n 4 127.0.0.1>nul
rem clear session
del /q \\%%a\c$\windows\system32\remote.vbs
del /q “%CurDir%\remote.vbs”
)
)