Page 1 of 1

Batch script to login to multiple windows server

Posted: 31 Oct 2019 00:25
by srini
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

Re: Batch script to login to multiple windows server

Posted: 31 Oct 2019 05:22
by aGerman
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

Re: Batch script to login to multiple windows server

Posted: 31 Oct 2019 08:10
by bakemonogatari
an easy way would be to save credentials using Remote Desktop Connection (mstsc.exe)...

Re: Batch script to login to multiple windows server

Posted: 31 Oct 2019 09:21
by srini
Thanks steffen , can this be achieved through powershell ? If so can you please help me

Srinivas

Re: Batch script to login to multiple windows server

Posted: 31 Oct 2019 09:26
by aGerman
Maybe someone else can. I can't.

Steffen

Re: Batch script to login to multiple windows server

Posted: 31 Oct 2019 11:01
by elzooilogico
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.

Re: Batch script to login to multiple windows server

Posted: 01 Nov 2019 21:17
by srini
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 .

Re: Batch script to login to multiple windows server

Posted: 01 Nov 2019 22:45
by srini
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 .

Re: Batch script to login to multiple windows server

Posted: 27 Nov 2019 10:55
by Yellow_13
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?