Jump to content

Add a random password in a comspec cmd


gogloc
 Share

Go to solution Solved by SOLVE-SMART,

Recommended Posts

$pwd = ""
Dim $aSpace[3]
$digits = 15
For $i = 1 To $digits
    $aSpace[0] = Chr(Random(65, 90, 1)) ;A-Z
    $aSpace[1] = Chr(Random(97, 122, 1)) ;a-z
    $aSpace[2] = Chr(Random(48, 57, 1)) ;0-9
    $pwd &= $aSpace[Random(0, 2, 1)]
Next
Run(@COMSPEC & ' /c "echo Random Password !!!!!!!!!!!!!!!!!!! (" & $digits & " digits): " & $pwd & @CRLF) > C:\Users\Admin\Desktop\test.txt ',@SYSTEMDIR,@SW_SHOW)

Link to comment
Share on other sites

  • Solution

Hi @gogloc,

try this 😉 :

Global $sFilePath = @DesktopDir & '\test.txt'
Global $pwd       = ''
Global $digits    = 15

Dim $aSpace[3]

For $i = 1 To $digits
    $aSpace[0] = Chr(Random(65, 90, 1))  ; A-Z
    $aSpace[1] = Chr(Random(97, 122, 1)) ; a-z
    $aSpace[2] = Chr(Random(48, 57, 1))  ; 0-9
    $pwd &= $aSpace[Random(0, 2, 1)]
Next

Run(@ComSpec & ' /K "echo Random Password !!!!!!!!!!!!!!!!!!! ("' & $digits & '" digits): "' & $pwd & '" > "' & $sFilePath & '"', '', @SW_SHOW)

But why do you want to make it through the command line, when you're redirecting the output to a file anyway?
You can write directly to an file without @ComSpec.

Best regards
Sven

________________
Stay innovative!

Stay innovative!

Spoiler

🌍 Au3Forums

🎲 AutoIt (en) Cheat Sheet

📊 AutoIt limits/defaults

💎 Code Katas: [...] (comming soon)

🎭 Collection of GitHub users with AutoIt projects

🐞 False-Positives

🔮 Me on GitHub

💬 Opinion about new forum sub category

📑 UDF wiki list

✂ VSCode-AutoItSnippets

📑 WebDriver FAQs

👨‍🏫 WebDriver Tutorial (coming soon)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...