Avatar of kenfitzgerald
kenfitzgeraldFlag for United States of America asked on

How to auto answer a login script

I'm using a login script to map drives to shared folders. I'm also running terminal services remote apps. After my users login and then login to the remote apps they randomly get the command prompt box appear during the login script that stops with a question that says there are pending connections to the drive tis mapping and asks if they want to force them closed. If they type Y and hit enter out of it everything works, but if they close it or ignore it not all of the drives get mapped. I want to be able to auto answer yes in my script so my end users can't mess it up. How would I do this?
Microsoft Server AppsMicrosoft Legacy OSMicrosoft Development

Avatar of undefined
Last Comment

8/22/2022 - Mon

thats the problem running net use scripts on terminal services, use Group Policy to deploy your network drives instead.  

Ken, if you want to use logon/logoff startup/shutdown scripts to perform tasks on machines (including terminal servers) consider using KiXtart. Its very very good. There is so much functionality and documentation available where a lot of the processes like mapping drives have been simplified into functions that you call without the need for any user interaction.


Manual - http://www.kixtart.org/binary/kix2010.pdf

You can use it to map drives like this:


Try making your logon script first Delete/Disconnect mapped drives and then remap/reconnect (all in same script).
You'll find that it will cooperate much better this way.
Dim  WshNetwork
Set WshNetwork = CreateObject("WScript.Network")
Set clDrives = WshNetwork.EnumNetworkDrives
For i = 0 to clDrives.Count -1 Step 2
    WSHNetwork.RemoveNetworkDrive clDrives.Item(i), True, True
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
Lee W, MVP

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question

net use * /delete /yes is the batch delete all mapped drives method