Jump to content

Variable to a net use DOS

Recommended Posts

Am I missing something thats gonna slap me in the face here ?

I want to pass a variable to a net use command so I [ well not me, teachers ] can map a drive to a students home dir. Code I have is as follows:

; AutoIt Version:    2.64
; Language:          English
; Platform:          WinXP
; Author:            Matt ********************  
; Script Function:  Maps a drive to a students home directory


InputBox, usernum, Student Home Drive Mapper, Please Enter number corrasponding to the User ID.
    FileReadLine, user, c:\\matt\\students2.txt, %usernum%
        MsgBox, 4, Is this the student ?, %user%
            IfMsgBox, NO, Goto, start
;map drive

run, %comspec% /c net use s: /d
    sleep, 2000
        run, %comspec% /c net use s: \\\\*****01\\%user%

I have tried to use the %clipboard% variable too but no luck - is there a way I can get the %user% variable to DOS so I can map the drive ?

Link to post
Share on other sites

Have you tried using EnvSet and EnvUpdate? Check Helpfile under Function Reference, Environment Management. You may have to create an environment variable to use in the OS.

Example: ; Set TMPCLASSPATH environment variable

EnvSet("TMPCLASSPATH", $Nline)

with $Nline being the new value you want to set it to.

I hope this helps.


Link to post
Share on other sites

Thanks for the tips, its a little strange why it won't work, the only thing I can think of is that I am testing it on my laptop which is not part of the domain. I tried the net use from my laptop just to see if it would work - [ not using the variable ] and it worked fine.

I'll try a runwait tomorow and also try it on a PC which is part of the domain.

Link to post
Share on other sites
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...