Question Locked

Remote Batch files

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
I am trying to run a batch file on all my computer in my Active directory at the same time. I know i can run it a startup or login. But i need to make a change in the middle of the night without any user interaction. Please help.

3 replies

by ic-it

Will run with system credentials. Is there a specific reason that the batch file needs user interaction?
Otherwise just use a WOL and let it run.

by scott_heath

I'm sure someone will say this is too complicated, but I like to use vbscript for stuff like this. You can use something like this:

Set oRoot = GetObject("LDAP: //RootDSE")
strRoot = oRoot.Get("defaultNamingContext")
path = "LDAP://" & strRoot
Set oConnect = CreateObject("ADODB.Connection")
Set oCommand = CreateObject("ADODB.Command")
oConnect.Provider = "ADsDSOObject"
oConnect.Open "Active Directory Provider"
Set oCommand.ActiveConnection = oConnect
oCommand.CommandText = "SELECT name FROM '" & path & "' WHERE objectClass='Computer'"
Set result = oCommand.Execute
For i = 1 to result.recordcount
computername = result(0).value
{code to do stuff}
result.movenext
Next

This discussion is closed to new replies.