wierd batch file behavior

Discussion in 'Scripting' started by Sasi, May 28, 2007.

  1. Sasi

    Sasi Guest

    this is the batch file I've written:

    net user /add Admin ~!@#$%^&*()_+
    net user Admin ~!@#$%^&*()_+
    net localgroup Administrators /add Admin

    net user /add Admin ~!@#$%^&*()_+ /domain
    net user Admin ~!@#$%^&*()_+ /domain
    net localgroup Administrators /add Admin /domain

    it is supposed to create an account named "Admin" in case of laking such
    account,set and/or change its password to the 13 consequent keys of the upper
    row of a standard keyboard (tilda,exlamation,at sign,sharp,and etc till
    backspace),and finally make that account an administrator.
    the problem is that the account is created and it IS joined to the
    administrators group,both locally and on domain;but the password is not set
    as expected.I tried everything I would think of,but none was the password it
    has set.
    I want to know ,considering exactly the script text above,what the Admin
    password would be.
    I've scheduled this batch file to be run every week on a remote computer and
    I have no access to it to change the designated password,so I need to recover
    this password.
    Sasi, May 28, 2007
    1. Advertisements

  2. Sasi

    Al Dunbar Guest

    This is not weird batch file behaviour, as you should always expect trouble
    when dealing with special characters. In addition to having syntactical
    meaning to cmd.exe, some characters may not be accepted as valid password
    characters (but I do not know that for a fact).

    If you would change the password to something a little less likely to cause
    problems (i.e. all letters and digits), then I think you will find it works.

    Try these commands:

    set zzz=~!@#$%^&*()_+
    set zzz

    and I think you will see that zzz was set to ~!@#$%&*()_+ rather than to

    Al Dunbar, May 29, 2007
    1. Advertisements

  3. Sasi

    Jeremy Guest

    Its the ampersand screwing it up. This means to run two command in the CMD

    So if you wrote:

    ECHO FOO&cmd.exe
    This would echo FOO to the current CMD shell and the spawn a new one.

    It wont be particularly happy with the brackets either, but this may still
    work since you don't have a FOR loop or an IF statement.
    Jeremy, May 29, 2007
  4. Sasi

    Sasi Guest

    so what do you guys suggesting? based on your comments what would the
    password be?
    I tested al dunbar's SET command and it was exactly as he said.it omitted ^
    sign.but the remaining 12 character sequence was not the password.
    I also tested jeremys' .according to him it must be ~!@#$%^ ;but it was not
    Sasi, May 30, 2007
  5. Sasi

    Jeremy Guest

    Try the command without the & or the ^ or the () this should work.
    Jeremy, May 31, 2007
  6. Sasi

    Sasi Guest

    thank you both guys.
    based on your comments,I ran the batch file in a cmd window and watched it
    it actually ommited both % and ^ symbles during execution;so the password
    will be the whole 13 sequence,without % and ^ symbols.
    Sasi, Jun 1, 2007
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.