Sign in to follow this  
Followers 0
CoffeeBean

Problems with @ComSpec, 'net user' and DriveMapAdd

5 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites



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

  • RunWait (@ComSpec &'/k' & $cmd)
should be
  • RunWait (@ComSpec &'/k ' & $cmd)
1 person likes this

AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line

Share this post


Link to post
Share on other sites

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 ;)
1 person likes this

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Spaces? >_< Thanks Quaal, Danny and Jos - the spacing around

' /k '
fixed it!

Share this post


Link to post
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
Sign in to follow this  
Followers 0