Batch File Window Closing Too Soon

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
platypus
Posts: 8
Joined: 29 Dec 2016 18:27

Batch File Window Closing Too Soon

#1 Post by platypus » 21 Mar 2018 19:09

I created a batch file that requires a 60 character password before it will execute
commands. I've got a script on a couple of USB sticks that display the password
in a text file. After the password appears it's copied and pasted into the batch
file window.

Ocassionally, the batch file window instantly closes after copying and pasting
the password. The commands it's suppose to execute are ignored. Rebooting
my computer usually fixes the problem. Why is this happening and is there a
solution?

ShadowThief
Expert
Posts: 1166
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: Batch File Window Closing Too Soon

#2 Post by ShadowThief » 22 Mar 2018 01:48

Without seeing the script, it's impossible to say.

platypus
Posts: 8
Joined: 29 Dec 2016 18:27

Re: Batch File Window Closing Too Soon

#3 Post by platypus » 22 Mar 2018 20:26

Well, the batch file is encrypted for a reason. I'm a partner in a business, so I
can't upload the contents. I could create a similar batch file, that is not related
to my business.

I'm 90% certain this ocassional problem is a glitch with the operating system.

There is a workaround solution. The script that runs from the USB sticks could
be expanded. Instead of a manual copy and paste, the script would automatically
enter the 60 character password when the batch file window appears.

ShadowThief
Expert
Posts: 1166
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: Batch File Window Closing Too Soon

#4 Post by ShadowThief » 23 Mar 2018 02:15

The script is using SendKeys, isn't it? That's the only situation I've ever seen where scripts interact with GUIs, but only sometimes. You can generally get around SendKeys being a finicky piece of crap by throwing in Sleep commands between everything. It's not ideal, but it increases the success rate. A better solution is to use literally everything else, and it sounds like you managed to either take advantage of some command line parameters, or get lucky that you only needed to enter one bit of information that you could echo and pipe to the script. Either way, glad you got it working.

Post Reply