Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am using an application that requires several attempts to log in (because of overloaded servers).

This app has no "remember my password" feature.

Therefore, I would like to make a script (preferably a .bat script), that would first copy my password into the clipboard -so that I don't have to retype my password on every log on attempt- , then launch the application (easy part)

Is this possible with a MS-DOS command ? Do I need a little exe or another script language ?

I'm obviously looking for the quickest solution to implement.

Thanks in advance for your ideas

share|improve this question
    
I don't think you can solve this in a .bat file, have a look at autohotkey it should fix your problem in a few lines, if you already know a programming language this should be fairly easy. –  Guillermo Siliceo Trueba Jan 9 '11 at 17:51

4 Answers 4

up vote 12 down vote accepted

http://www.petri.co.il/software/clip.zip

C:\>echo abc| clip  <-- copies abc to the clipboard.

EDIT
The main thing is that clip command but as pointed out by Asu, a line like echo abc will also send a \r\n (which is a new line). If you want to avoid that, then that's a very standard issue solved by replacing echo texttoecho, with echo|set/p=texttoecho So C:\>echo|set/p=texttoecho|clip

share|improve this answer
    
Nice exe. This will do the work ! –  Sebastien Jan 9 '11 at 22:31
    
On a related note, in the cmd window, left click the top left, then properties, then in the options tab, check the box that says quickedit mode. Now you can copy/paste fast. click hold and drag with the mouse over what you want to copy selecting it, press ENTER to copy. Right click to paste. –  barlop Jan 9 '11 at 22:49
    
and to paste to the command line, right mouse click. to get it within a batch file, you will need to write a tiny script or executable in some other language like vbs, perl, c to do it or compile somebody elses stackoverflow.com/questions/1704455/… btw, .vbs uses wshextra.dll set clip = createobject("WshExtra.Clipboard") Looks like Perl does it in two tiny lines and needs no extra file. –  barlop Mar 22 '12 at 18:13
    
and the webpage on petri's site that mentioned it though many others just link to the file. petri.co.il/quickly_copy_error_and_display_messages.htm –  barlop Dec 12 '12 at 15:29

barlop's option isn't entirely correct because echo will add a newline character to your password breaking it.

What you need to use instead is this:

echo|set /p=MyPassWord|clip

This way the string will be copied to the clipboard as is.

share|improve this answer
    
This should be an accepted answer. Helped me with new line character and quotation marks. –  Piotr Sobczyk Sep 17 '13 at 15:16
    
should have just edited the existing answer –  endolith May 24 at 3:20
    
@endolith I didn't have the privileges to do that at the time. –  Asu May 25 at 18:29

AutoIt v3 can automate windows, which makes trying several login attempts easy.

AutoIt v3 is a freeware BASIC-like scripting language designed for automating the Windows GUI and general scripting. It uses a combination of simulated keystrokes, mouse movement and window/control manipulation in order to automate tasks in a way not possible or reliable with other languages (e.g. VBScript and SendKeys). AutoIt is also very small, self-contained and will run on all versions of Windows out-of-the-box with no annoying "runtimes" required!

AutoIt was initially designed for PC "roll out" situations to reliably automate and configure thousands of PCs. Over time it has become a powerful language that supports complex expressions, user functions, loops and everything else that veteran scripters would expect.

They have good examples, documentation and a solid community that can help you with script problems.

Although, you might be better off asking if they could solve the problem with their overloaded servers, as automating requests might only make the problem worse for them...

share|improve this answer
    
This tools looks very useful, however I will stick to the manual Ctrl - V, it won't take me much longer now that I don't have to type the password or manually Ctrl-C it. –  Sebastien Jan 9 '11 at 22:30
    
@Sebastien: I don't understand, you're asking for a script to help you fill in the password more easily and yet just accept a solution that just does a copy/paste? Did you know that if you select the password circles in the password box that you can just copy/paste them from there? Please note that you can vote answers up with the arrow above the number to reward reputation. –  Tom Wijsman Jan 9 '11 at 23:22
1  
The first answer actually exactly fulfills the need (pretty basic) I described in the question. Now when I want to take the automation a step further, I'll definitely take a look at AutoIt ;) [and about the 'vote up', I don't have the reputation for it yet] –  Sebastien Jan 10 '11 at 8:56
    
"password circles" Do you mean asterisks? They're not circles! Try typing them with a huge font in Ms Word ;-) Err, well, I guess some software uses circles! –  barlop Jan 11 '11 at 23:10
    
@barlop: No, not asterisks. Circles are indeed wrong, I think they are called "dots", see this picture. Next time, I'll type "password characters" which should keep me safe until someone invents "password figures"... –  Tom Wijsman Jan 11 '11 at 23:18

I've myself encountered a similar scenario and here's how I've solved it.

First, I store my passwords in the Windows Credential Vault (Windows Vista and greater). For this, I use Python's keyring library, but you can just as well use something like CredMan (Powershell) to manage them. Using the Windows Credential Vault means the password never has to be typed on the command line, so is unlikely to leak (such as through a command-line history).

Second, I use a tool like clip to copy the password to the clipboard.

You may find you want to combine the two with your own PowerShell script that grabs the text from the credential manager and puts it on the clipboard. The script could be something as simple as:

$cred = Read-Creds 'Some System'
[Windows.Forms.Clipboard]::SetText($cred.CredentialBlob)

Then, all you have to do is add the password to 'Some System' in Windows Credential Manager and that script will magically put the password on the clipboard on command.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.