Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: Help creating a migration batch properly

1 Week Ago   #1
darthmalakit

Buenos Aires
 
 
Help creating a migration batch properly

hello there my friends im in a migration process, and i need to create this batch properly

what i need are 2 things:

1) to this batch create a sub batch with mapped drives
*so far where im stuck in, is in doing net use >> g:\%username%\migracion_vieja\mapped drives.txt
*but idk how to do a batch file from that txt wich is telling me the path of the current mapped drives to import then from doing a bath file.

2) to export connected networks printers into a txt


this is my batch, is in spanish so im sorry in advance for that. basicly what is doing is exporting to a txt system info, like hostname, operative system name, domain, etc.

@echo chequeando informacion pc vieja

mkdir g:\%username%
mkdir g:\%username%\migracion_vieja

systeminfo | find /i "Nombre de host" >> g:\%username%\migracion_vieja\Nombre_De_Host_vieja.txt
systeminfo | find /i "Nombre del sistema operativo" >> g:\%username%\migracion_vieja\Nombre_del_sistema_operativo_vieja.txt
systeminfo | find /i "Dominio" >> g:\%username%\migracion_vieja\Dominio_vieja.txt
systeminfo | find /i "Fabricante del sistema" >> g:\%username%\migracion_vieja\Fabricante_Del_Sistema_vieja.txt
systeminfo | find /i "Modelo el sistema" >> g:\%username%\migracion_vieja\Modelo_Del_Sistema_vieja.txt
systeminfo | find /i "Tipo de sistema" >> g:\%username%\migracion_vieja\Tipo_De_Sistema_vieja.txt
ipconfig >> g:\%username%\migracion_vieja\ip_vieja.txt

@echo Completeda migración vieja!

thanks in advance and forgive for my english if is not clearly what i need =)

Best regards jonathan


My System SpecsSystem Spec
.
1 Week Ago   #2
Megahertz07

Windows 7 HP 64
 
 

Buenas tardes hermano.

What you want to achieve?
From where you want to migrate? to where?
My System SpecsSystem Spec
1 Week Ago   #3
darthmalakit

Buenos Aires
 
 

hello im doing a migration. / hola estoy haciendo una migracion

I have to take from the old pc all the info,including domain, host name etc, as well as mapped drives and mapped em into a new pc. as well as connected network printers export ´em into a txt / tengo que tomar los datos de la pc vieja, eso incluye dominio, nombre de host, etc y necesito en el batch que estoy haciendo, que el mismo cree un batch con las unidades de red conectadas y exportar a un txt las impresoras de red conectas.

so far this is what im doing / hasta ahora esto es lo que pude hacer

@echo chequeando informacion pc vieja

mkdir g:\%username%
mkdir g:\%username%\migracion_vieja

systeminfo | find /i "Nombre de host" >> g:\%username%\migracion_vieja\Nombre_De_Host_vieja.txt
systeminfo | find /i "Nombre del sistema operativo" >> g:\%username%\migracion_vieja\Nombre_del_sistema_operativo_vieja.txt
systeminfo | find /i "Dominio" >> g:\%username%\migracion_vieja\Dominio_vieja.txt
systeminfo | find /i "Fabricante del sistema" >> g:\%username%\migracion_vieja\Fabricante_Del_Sistema_vieja.txt
systeminfo | find /i "Modelo el sistema" >> g:\%username%\migracion_vieja\Modelo_Del_Sistema_vieja.txt
systeminfo | find /i "Tipo de sistema" >> g:\%username%\migracion_vieja\Tipo_De_Sistema_vieja.txt
ipconfig >> g:\%username%\migracion_vieja\ip_vieja.txt
@echo Completeda migración vieja!

*so far where im stuck in, is in doing net use >> g:\%username%\migracion_vieja\mapped drives.txt / por ahora en donde estoy trabado es haciendo un net use y exportando eso a un txt
*but idk how to do a batch file from that txt wich is telling me the path of the current mapped drives to import then from doing a bath file. / pero no se como hacer un batch de ese txt que me esta diciendo la direccion de las unidades de red conectadas, para poder importarlas desde un batch a una nueva pc.

2) to export connected networks printers into a txt / exportar impresoras de red conectadas a un txt.
My System SpecsSystem Spec
.

1 Week Ago   #4
Paul Black

Win 7 HP SP1 64-bit Vista HB SP2 32-bit Linux Mint 18.3
 
 

Hi darthmalakit,

Welcome to SevenForums!

I don't speak Spanish but I can see that you are using systeminfo!
You may also want to look at wmic.

As an example . . .

Code:
For /f "tokens=2 delims='='" %%A In ('wmic NETLOGIN Get HomeDirectory /value') Do Set HomeDirectory=%%A
I hope this helps!
My System SpecsSystem Spec
1 Week Ago   #5
darthmalakit

Buenos Aires
 
 

Quote   Quote: Originally Posted by Paul Black View Post
Hi darthmalakit,

Welcome to SevenForums!

I don't speak Spanish but I can see that you are using systeminfo!
You may also want to look at wmic.

As an example . . .

Code:
For /f "tokens=2 delims='='" %%A In ('wmic NETLOGIN Get HomeDirectory /value') Do Set HomeDirectory=%%A
I hope this helps!
thank u for u reply. I dont know what that command does.

a) What im needing is ,to be as much as clarifing as possible is : from old pc, take current mapped drives export em into a batch from those current mapped drives from %username%, and then in the new pc. Just click on that batch and map those drives from old pc to new one again.

b) to export to a txt file, current path of %username% mapped printers. to then manually map those printers again (wich they arent local)
exampe \\sfs-1\printer name
From there i can put that into run command.

Yes, what im doing in the migration process, is taking systeminfo that i need, from the old pc, and the new one, and in order to improve the current process i need to made a batch from current map drives fold old pc, and import em with that batch to new one, as well as mapped printers
My System SpecsSystem Spec
1 Week Ago   #6
Paul Black

Win 7 HP SP1 64-bit Vista HB SP2 32-bit Linux Mint 18.3
 
 

Hi darthmalakit,

Have you tried . . .

[1] net use [command line]?
[2] To output the file to the desktop for a list of the current mapped drives for the current user and current connection try this . . .

net use > "%userprofile%\Desktop\Mapped_Drives.txt"

Is this the sort of thing you are looking for?
My System SpecsSystem Spec
6 Days Ago   #7
darthmalakit

Buenos Aires
 
 

Quote   Quote: Originally Posted by Paul Black View Post
Hi darthmalakit,

Have you tried . . .

[1] net use [command line]?
[2] To output the file to the desktop for a list of the current mapped drives for the current user and current connection try this . . .

net use > "%userprofile%\Desktop\Mapped_Drives.txt"

Is this the sort of thing you are looking for?
From there is where im stuck

current command lines is:

net use | find "slash slash" > d:\mapped_drives.txt

that gives into result as just using as example of my current mapped drives, just for testing

Conected W: \\192.168.1.XXX\Volume_2 Microsoft Windows Network

in order to clean that i did a powershell command line wich do this:

$drivelist = (Get-Content C:\prueba\drivelist.txt | Select-String -Pattern "") | Out-String
$drivelist = $drivelist -replace("Conected","")
$drivelist = $drivelist -replace("Microsoft Windows Network","")
$drivelist = $drivelist -replace(" ","")
$drivelist = $drivelist -replace(':\\',': \')
$drivelist | Out-File C:\prueba\drivelist2.txt

foreach ($line in [System.IO.File]::ReadLines("C:\prueba\drivelist2.txt")) {
$parts = $line.split(" ")
net use $parts[0] $parts[1]
}

wich give the clean path

W: \\192.168.1.XXX\Volume_2

then i did

cls
#Define Functions
(gc G:\migracion_vieja\unidades_de_red_limpio.txt) -replace '\S+$','$& /persistent:yes' | out-file "G:\preparando.txt"

wich adds /persistent yes to the end of each line

then i did

$Lines = Get-Content .\preparando.txt
$OutputPath = "g:\discos_mapeados.bat"
foreach ($Line in $Lines) {
$Line = $line.Insert(0,'net use ')
$Line += ''
Write-Output $Line | Out-File $OutputPath -Append

Wich add net use to the begginig of each line and create the batch file

thats what i wanted. thank u
My System SpecsSystem Spec
.
Reply

 Help creating a migration batch properly




Thread Tools




Similar help and support threads
Thread Forum
Creating the PPPOE internet connection using batch file
I have a PPPoE internet connetion from my ISP. Every time I want to access the internet connection I have to goto the setting and in that I have to open it and then have to dial it. This is the traditional way to log in but I wanted to make a batch file in which the PPPoE user name and password is...
Network & Sharing
Creating Batch File with Robo Copy
Hi I am currently running the following to supposedely create a directory IE V:\Backup Folder\Pictures\Backup 21-05-2012 robocopy /e "c:\users\jon\pictures" "v:\Backup Folder\Pictures\Backup %date:~-10,2%-%date:~-7,2%-%date:~-4,4%" Evrything works fine except the backed up pictures folder is...
General Discussion
Creating .batch to run at shutdown
I would like to know how to create a .batch file and have it run at the shut down of the computer,Here are the commands: netsh int ip reset reset.log netsh int ip delete arpcache netsh winsock reset ipconfig /flushdns Thanks
Performance & Maintenance
Help Needed Creating Batch File
Hi, I have 2 files that are in the same directory which I want to start one after the other. I have created a simple batch file like this which opens 2 files at the same time. Example Start Server.exe Start Game.exe
General Discussion
Creating a welcoming batch file...
I need help creating batch file that will do the following... I want it to echo "Welcome (insert name here)." I want it to say "How are you today, good or bad?" If G, I want it to display, "That's great to know, sir! Would you like me to open your homepage? If Y, I want it to execute cd...
Software


Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd

All times are GMT -5. The time now is 16:55.
Twitter Facebook