Sign in to follow this  
Followers 0
southboyj

Mapping C$ drive using variables

4 posts in this topic

Any advice will be greatly appreciated.

1 - I am asking the user for input

$UserID entry is in DOMAIN\USER format (and is admin on target PC)

$Computername has been entered as computername, IP address and \\computername and \\IP address

2 - Mapping the C$ drive of another computer

3 - Copying a file from the same directory as the script to that drive.

So far, I am not able to map the drive successfully. Is there some syntax error in the DRIVEMAPADD line? Something else?

Script is as follows:

$UserID = InputBox ("User Name", "Enter User name", "", "")

$Password = InputBox ("Password", "Enter Password","", "X")

$ComputerName = InputBox ("Computer Name", "Enter Computer Name","", "")

DriveMapAdd ("J:", "$Computername\c$", 0, "$UserID", "$Password")

FileCopy ("@ScriptDir\Filename.txt","J:", 1)

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

try

$UserID = InputBox ("User Name", "Enter User name", "", "")
$Password = InputBox ("Password", "Enter Password","", "X")
$ComputerName = InputBox ("Computer Name", "Enter Computer Name","", "")

DriveMapAdd ("J:","\\" & $Computername & "\c$", 0, $UserID, $Password)
FileCopy (@ScriptDir & "\Filename.txt","J:", 1)

you can just enter an IP or Computername with out any slashes

Edited by tlman12

Share this post


Link to post
Share on other sites

try

$UserID = InputBox ("User Name", "Enter User name", "", "")
$Password = InputBox ("Password", "Enter Password","", "X")
$ComputerName = InputBox ("Computer Name", "Enter Computer Name","", "")

DriveMapAdd ("J:","\\" & $Computername & "\c$", 0, $UserID, $Password)
FileCopy (@ScriptDir & "\Filename.txt","J:", 1)

you can just enter an IP or Computername with out any slashes

Thanks for the quick response. I will try this when I return t work next week.

Share this post


Link to post
Share on other sites

Thanks. Worked great

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