PC Review


Reply
Thread Tools Rate Thread

CMD.exe batch for net use

 
 
Richhall
Guest
Posts: n/a
 
      21st May 2008
Apologies if I should be using msdos batch group. I am using Widnows
XP and had a simple batch that had 3 variables at the prompt to create
a net use connection:

net use u: /d
rem *****************************************
rem %1 is IP address of target
rem %2 is username
rem %3 is password
rem -----------------------------------------
net use u: \\%1\c$ %3 /userOMAIN\%2 /PERSISTENT:NO
pause

However I want this to be run from a file not the command line. I've
searched the group but can's see it without using 3rd party software
how I can prompt for the %1 etc. I am not exactly sure what I am
doing, but got this far:

set /p IP=Enter Target IP:
set /p User=Username:
set /p Pass=Password:
echo %IP%
echo %User%
echo %Pass%
net use u: /d
rem *****************************************
rem %1 is IP address of target
rem %2 is username
rem %3 is password
rem -----------------------------------------
net use u: \\%1\c$ %3 /userOMAIN\%2 /PERSISTENT:NO
pause

How do I set the values entered in, as the %1, %2 and %3 values please?
 
Reply With Quote
 
 
 
 
Pegasus \(MVP\)
Guest
Posts: n/a
 
      21st May 2008

"Richhall" <(E-Mail Removed)> wrote in message
news:8625b882-7198-4f57-92aa-(E-Mail Removed)...
> Apologies if I should be using msdos batch group. I am using Widnows
> XP and had a simple batch that had 3 variables at the prompt to create
> a net use connection:
>
> net use u: /d
> rem *****************************************
> rem %1 is IP address of target
> rem %2 is username
> rem %3 is password
> rem -----------------------------------------
> net use u: \\%1\c$ %3 /userOMAIN\%2 /PERSISTENT:NO
> pause
>
> However I want this to be run from a file not the command line. I've
> searched the group but can's see it without using 3rd party software
> how I can prompt for the %1 etc. I am not exactly sure what I am
> doing, but got this far:
>
> set /p IP=Enter Target IP:
> set /p User=Username:
> set /p Pass=Password:
> echo %IP%
> echo %User%
> echo %Pass%
> net use u: /d
> rem *****************************************
> rem %1 is IP address of target
> rem %2 is username
> rem %3 is password
> rem -----------------------------------------
> net use u: \\%1\c$ %3 /userOMAIN\%2 /PERSISTENT:NO
> pause
>
> How do I set the values entered in, as the %1, %2 and %3 values please?


You're very close. Try this version:
@echo off
set /p IP=Enter Target IP:
set /p User=Username:
set /p Pass=Password:
echo %IP%
echo %User%
echo %Pass%
net use u: | find "\\" && net use u: /d
net use u: \\%IP%\c$ /userOMAIN\%User% %Password%
net use /PERSISTENT:NO
pause


 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
A script/batch to kill a batch file from scheduled tasks? Bogdan Windows XP Configuration 1 31st Jul 2009 06:05 AM
batch file call from a macro - how ? and required batch format VB-rookie Microsoft Excel Programming 3 5th Sep 2008 10:33 PM
calling multiple batch files from within a batch file yawnmoth Windows XP General 3 26th May 2008 06:47 PM
Save batch window msgs to a file from the batch prog Stephen Rainey Windows XP General 3 10th Jan 2007 12:50 AM
Photo Editor Batch supporting batch compression JPG files 29150 Freeware 2 23rd Jun 2003 06:02 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:44 PM.