Batch script to login to multiple windows server

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
srini
Posts: 4
Joined: 31 Oct 2019 00:20

Batch script to login to multiple windows server

#1 Post by srini » 31 Oct 2019 00:25

Hi All,

Good Day . Please help me with below requirement .

1) Batch script to login to multiple windows servers from a central window server without prompting for userid and password.
2)script should also click ok on the security agreement once credentials are provided .

Thanks ,
Srinivas

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Batch script to login to multiple windows server

#2 Post by aGerman » 31 Oct 2019 05:22

I have no experiences with networking and can't tell what is needed for 1). But 2) can't be done using Batch. It doesn't interact with graphical interfaces. And in case you're talking about the UAC prompt then I don't think that any software can confirm it (at least I hope it is not possible since it would be a security hole).

Steffen

bakemonogatari
Posts: 21
Joined: 08 Jul 2019 05:22

Re: Batch script to login to multiple windows server

#3 Post by bakemonogatari » 31 Oct 2019 08:10

an easy way would be to save credentials using Remote Desktop Connection (mstsc.exe)...

srini
Posts: 4
Joined: 31 Oct 2019 00:20

Re: Batch script to login to multiple windows server

#4 Post by srini » 31 Oct 2019 09:21

Thanks steffen , can this be achieved through powershell ? If so can you please help me

Srinivas

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Batch script to login to multiple windows server

#5 Post by aGerman » 31 Oct 2019 09:26

Maybe someone else can. I can't.

Steffen

elzooilogico
Posts: 128
Joined: 23 May 2016 15:39
Location: Spain

Re: Batch script to login to multiple windows server

#6 Post by elzooilogico » 31 Oct 2019 11:01

with cmdkey yoy can store credentials to access computers over the net. read the

Code: Select all

cmdkey
command help.
long ago I used a batch script which executes cmdkey and wmic to run proccesses and fetch its output over many servers. no need to logon, nor any user session on remote server, provided not gui app was needed to be run.

srini
Posts: 4
Joined: 31 Oct 2019 00:20

Re: Batch script to login to multiple windows server

#7 Post by srini » 01 Nov 2019 21:17

Thanks elzooilogico, I have used WMIC in batch script . But I am encountering peculiar issue. Code goes like below .Aim is to get windows service status and if it is in running then execute next statements .

For /f %%a in (servers.txt) do (

for /f "tokens=*" %%H in (' wmic /node:%%a Service WHERE "Name = 'wuauserv' " GET State ^ | findstr "Running" ') do (

if /i %%H EQU "Running" do (

echo %%H>>D:/status.txt
)
)
)

Expected output is to get the status in the status.txt when if condition is satisfied . But the control never goes inside if , which means the condition is not satisfied . But when I comment the IF condition and try to execute the status file is being created and text inside is Running . Now if %%H contains Running then why is the if condition not getting validated .Please help .

Output for wmic is : State=Running but this when validated against if statement its failing .

srini
Posts: 4
Joined: 31 Oct 2019 00:20

Re: Batch script to login to multiple windows server

#8 Post by srini » 01 Nov 2019 22:45

I have resolved my earlier query , but now facing issue with below
for /f %%J in (mine.txt) do (
for /f %%H in ('wmic /node:%%a Service WHERE "Name = '%%J'" GET State ^| findstr "Running" ' )

how to assign variable %%J to Name as the script is not working , seems syntax error , please help .

Yellow_13
Posts: 5
Joined: 26 Nov 2019 10:02

Re: Batch script to login to multiple windows server

#9 Post by Yellow_13 » 27 Nov 2019 10:55

Okay, so it's impossible, if I got things right, to operate DOS on a multiple Windows server? It's too bad, I was looking at a way to coordinate my computer at home and my laptop - including the use of DOS - as I will soon spend a part of the year at one of these houses in Greece.
So, if I want to do so, I should look into a remote computer control program like TeamViewer?
Last edited by aGerman on 27 Nov 2019 11:37, edited 1 time in total.
Reason: @Yellow_13 First and last warning - this is no platform for advertising!

Post Reply