Solved How to send automatically enter command in .bat?

October 15, 2018 at 08:35:54
Specs: Windows 7
I have a batch script that syncronize date and time from PC "A" to PC "B", but after when script do "net Time" command appear a confirm question with yes (Y) or no (N). I have to give ENTER button of keyboard to complete procedure.
Is there a way to send automatically ENTER keyboard's button with a command in .bat script?

Thanks


See More: How to send automatically enter command in .bat?

Reply ↓  Report •

#1
October 16, 2018 at 05:43:40
✔ Best Answer
have you tried the /Y switch?

if you have:

Could you show me the script?

I might be able to simulate an enter press, but i need to know what im working with

i5-6600K[delid]@4.7GHz/4.3GHz@1.376v LLC=6 | 2x4GB Crucial-DDR4-2133CL15@14-14-14-28 1T 2700MHz@1.35v
MSI Armor RX 570 4GB@1180Mhz core@0.937v/2000MHz

message edited by hidde663


Reply ↓  Report •

#2
October 16, 2018 at 06:42:45
hi hidde663, this is the code:

NET TIME \\SERVER_A /SET

NET STOP W32TIME && NET START W32TIME

After first script, appear a confirm question if i want to syncronize time from SERVER_A.
I have to send Y/N, with Y that is the default answer, so i just send ENTER command to let continue the script


Reply ↓  Report •

#3
October 16, 2018 at 06:45:16
Guys, i have resolved.
After script NET TIME \\SERVER_A /SET i added /Y command like this:
NET TIME \\SERVER_A /SET /Y

With this code it works fine

thanks

message edited by marcob1984


Reply ↓  Report •

Related Solutions

#4
October 16, 2018 at 06:54:53
glad to hear :)

i5-6600K[delid]@4.7GHz/4.3GHz@1.376v LLC=6 | 2x4GB Crucial-DDR4-2133CL15@14-14-14-28 1T 2700MHz@1.35v
MSI Armor RX 570 4GB@1180Mhz core@0.937v/2000MHz


Reply ↓  Report •

Ask Question