Jump to content

Problems with @ComSpec, 'net user' and DriveMapAdd


Recommended Posts

Can anyone tell me why this isn't working? I've included the debug code also.

#include <File.au3> ; Not necessary for the block in question, but the goal of the script is to create some directories and install programs.
#RequireAdmin

;Set up Administrator account and map necessary Drive

$cmd = 'net user administrator /active:yes'
RunWait (@ComSpec &'/k' & $cmd) ; @error = 1, @extended = 2
$pwd = 'net user administrator password' @error = 1, @extended = 2
RunWait (@ComSpec &'/k' & '$pwd') ; @error = 1, @extended = 2
DriveMapAdd ('j:', '\\server\share', 'administrator', 'password') ; @error = 6, @extended = 0 <== ostensibly so since the administrator is never getting set on line 3.

I really appreciate your help!

Edit: Added #RequireAdmin - Same result.

Edited by CoffeeBean
Link to comment
Share on other sites

  • Developers

You forgot the space between the /k and the single quote.

  • RunWait (@ComSpec &'/k' & $cmd)
should be
  • RunWait (@ComSpec &'/k ' & $cmd)
You also need a space before the /K ;)

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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...