Script file help

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have been using the following little script file to remotely change the
time en-mass for some computers in our testing environment:

for /F %%a in (c:\PCs.txt) do psexec \\%%a net time \\Server_IP /set /y

The psexec.exe program runs a service on a remote machine without the need
for logon credentials to be specified. If it cannot reach a host for any
reason however, it stalls and does not continue with the other computer IPs
listed in the PCs.txt. Is there a way to do a ping check beforehand to ensure
that the machine is plugged in and on and if not to skip it?
 
Aaron said:
I have been using the following little script file to remotely change the
time en-mass for some computers in our testing environment:

for /F %%a in (c:\PCs.txt) do psexec \\%%a net time \\Server_IP /set /y

The psexec.exe program runs a service on a remote machine without the need
for logon credentials to be specified. If it cannot reach a host for any
reason however, it stalls and does not continue with the other computer IPs
listed in the PCs.txt. Is there a way to do a ping check beforehand to ensure
that the machine is plugged in and on and if not to skip it?

Simple:

for /F %%a in (c:\PCs.txt) do ping %%a -n 1 | find /i "bytes=" && psexec
\\%%a net time \\Server_IP /set /y

A more elegant method would be to insert a net time command
into the logon script to ensure that it runs each time the user
logs on.
 
The reason we are doing it this way rather than via a logon script is to
force a testing environment forward without disturbing the testers.

This may seem like a stupid question but.. What scripting language is this?
Is there an online resource for this where I can learn this myself? Or is
this just a form of basic/DOS?
 
You know domain members synch time every computer logon (ie bootup not user logon) to a domain. So it may be a waste of time what you are doing.
 
The commands you're using are ordinary Command Line
commands, with some control words added. From the
way they are coded I can tell that you copied them out
of a batch file. Here is a very simple batch file:

@echo off
copy c:\test\*.* d:\
echo The time is %time%
echo The current user's name is %UserName%
pause

Although many people call them "DOS" commands, this is
a misnomer. DOS is an operating system on its own,
same as Windows or Linux. There is no DOS under
Windows, only a Command Prompt (which admittedly
looks very much like DOS).
 
Back
Top