No announcement yet.

Workgroup Logon Script Issue

  • Filter
  • Time
  • Show
Clear All
new posts

  • Workgroup Logon Script Issue

    I use a Cyber Cafe management system which has 20 machines on a workgroup and I'm having issues connecting to one of my Servers which is on my domain.

    When I map a network drive (in explorer) on a client and restart the machine it's losing the password even though I have used a seperate set of credentials and selected reconnect at logon.

    Does anyone have a script or could they please take a look at the following and indicate where I have gone wrong, it's in the password part highlighted somewhere.

    @echo off
    net use_U:_\\mars\ecdl$ /user:clced.local\mapper_password:123456_/PERSISTENT:YES
    net time_\\mars_/set_/yes

    for your assistance I have used "_" for spaces in the script.

    I hope someone can point out the error of my ways.

  • #2
    Re: Workgroup Logon Script Issue

    You have to use the /savecred switch for saving the credentials.
    But then, the /savecred cannot be used together with the /user switch or password argument.

    When using the /savecred switch the command first tries the current user's credendials to logon to the remote computer, when that fails you'll be prompted to provide an alternate username and password. And because you used he switch the credentials will now be remembered for the mapping.

    @echo off
    start rundll32.exe keymgr.dll, KRShowKeyMgr
    net use s: \\computername_or_ip\sharename /savecred /persistent:[yes*/no]

    When you want to add the credentials programmatically you can do like this,
    copy the tool cmdkey.exe from your windows server:
    ::## save alternate credentials programmatically ##
    :: Note, alternate credentials are only used when the
    :: current user authentication is not accepted by the target computer!
    :: This batch is using cmdkey.exe, a tool from windows server. And
    :: assuming the tool is saved in the same folder as the batch file.
    :: if you create a persistent mapping then RUN THIS BATCH
    :: *ONLY ONCE* for every user logged-on to this computer
    :: (for a logonscript sample,
    ::  please read: )
    @echo off
    rem start rundll32.exe keymgr.dll, KRShowKeyMgr
    Set "RemoteComputer=computername_or_ip"
    "%~0\..\cmdkey.exe" /add:%remoteComputer% /user:domain\user /pass:[email protected]
    net use s: \\%remoteComputer%\sharename /persistent:yes


    But, incase you like to run this batch as part of your logon script then you don't have to and also a good practise not to use the parameter /persistent:yes

    here the correct syntax when running it as logonscipt,
    (note the credentials are hardcoded in the locally stored script and logonscripts are readable for any user on the computer!)
    net use s: /d /y
    net use s: \\computername_or_ip\sharename "[email protected]" /user:"domain\user" /persistent:no
    optionally, before making the mapping you can make use of cmdkey.exe in this logon batch too for removing any saved alternate usename and password for accessing the target computer that might exist for the current user. This just will ensure that no incorrect password for targetting the remote computer can be used (what possible could cause locking the domain account).
    Last edited by Rems; 30th May 2009, 08:34.

    This posting is provided "AS IS" with no warranties, and confers no rights.


    ** Remember to give credit where credit's due **
    and leave Reputation Points for meaningful posts