Help creating a migration batch properly

darthmalakit

New member
Local time
11:00 AM
Messages
4
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
 
Last edited:

My Computer

Computer type
PC/Desktop
OS
Buenos Aires
Buenas tardes hermano.

What you want to achieve?
From where you want to migrate? to where?
 

My Computers

System One System Two

  • Computer type
    PC/Desktop
    Computer Manufacturer/Model Number
    custom build
    OS
    Windows 7 HP 64
    CPU
    i5 6600K - 800MHz to 4200MHz
    Motherboard
    GA-Z170-HD3P
    Memory
    4+4G GSkill DDR4 3000
    Graphics Card(s)
    IG - Intel 530
    Monitor(s) Displays
    Samsung 226BW
    Screen Resolution
    1680x1050
    Hard Drives
    (1) -1 SM951 – 128GB M.2 AHCI PCIe SSD drive for Windows 7 and Lubuntu
    (2) -1 WD SATA 3 - 1T for Data
    (3) -1 WD SATA 3 - 1T for backup
    PSU
    Thermaltake 450W TR2 gold
    Keyboard
    Old and good Chicony mechanical keyboard
    Mouse
    Logitech mX performance - 9 buttons (had to disable some)
    Internet Speed
    500Mb/s
    Browser
    Firefox 64
    Other Info
    TinyWall firewall
  • Computer type
    Laptop
    System Manufacturer/Model Number
    Asus Q550LF
    OS
    Windows 7 Pro
    CPU
    i7-4500U 800MHz to 3.0GHz
    Motherboard
    Asus Q550LF
    Memory
    (4+4)G DDR3 1600
    Graphics Card(s)
    IG intel 4400 + NVIDIA GeForce GT 745M
    Sound Card
    Realtek
    Monitor(s) Displays
    LG Display LP156WF4-SPH1
    Screen Resolution
    1920 x 1080
    Hard Drives
    BX500 120G SSD for Windows and programs +
    1T HDD for data
    Internet Speed
    500 Mb/s
    Browser
    Firefox
    Other Info
    TinyWall firewall
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 Computer

Computer type
PC/Desktop
OS
Buenos Aires
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 Computer

Computer type
Laptop
Computer Manufacturer/Model Number
Fujitsu LIFEBOOK
OS
Win 7 HP SP1 64-bit Vista HB SP2 32-bit Linux Mint 18.3
CPU
Intel(R) Pentium(R) CPU P6200 @ 2.13GHz
Motherboard
FUJITSU FJNBB06
Memory
4.00 GB
Graphics Card(s)
Intel(R) Graphics Media Accelerator HD
Sound Card
[1] Realtek High Definition Audio [2] Intel(R) Display Audio
Screen Resolution
1366 x 768 x 32 bits (4294967296 colors) @ 59 Hz
Hard Drives
TOSHIBA MK5076GSX
Antivirus
AVG FREE
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 Computer

Computer type
PC/Desktop
OS
Buenos Aires
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 Computer

Computer type
Laptop
Computer Manufacturer/Model Number
Fujitsu LIFEBOOK
OS
Win 7 HP SP1 64-bit Vista HB SP2 32-bit Linux Mint 18.3
CPU
Intel(R) Pentium(R) CPU P6200 @ 2.13GHz
Motherboard
FUJITSU FJNBB06
Memory
4.00 GB
Graphics Card(s)
Intel(R) Graphics Media Accelerator HD
Sound Card
[1] Realtek High Definition Audio [2] Intel(R) Display Audio
Screen Resolution
1366 x 768 x 32 bits (4294967296 colors) @ 59 Hz
Hard Drives
TOSHIBA MK5076GSX
Antivirus
AVG FREE
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
 
Last edited:

My Computer

Computer type
PC/Desktop
OS
Buenos Aires
Back
Top