PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Hébergement serveur > ms..win.server.scripting > read disk serial number with .bat sript
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
read disk serial number with .bat sript

Réponse
 
LinkBack Outils de la discussion
Vieux 14/09/2007, 17h36   #1 (permalink)
bvb47
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut read disk serial number with .bat sript

hello!,

how can I read and assign the serial number of the hard drive or floppy to a
variable
in batch file?

thanks

  Réponse avec citation
Vieux 15/09/2007, 10h46   #2 (permalink)
bvb47 via WinServerKB.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut RE: read disk serial number with .bat sript

Hello!, thanks

I can't use the wmic because the service is dissabled on my XP's network
(wmic logicaldisk where "deviceid='c:'" get volumeserialnumber)

I think that one easy way to know the serial number is doing someting like:

dir c: > file.txt
and now read the serial number from the file. But I don't know how can I do
this.
(read regular expression from file or from a pipe)

thanks

J Ford wrote:
>With the aide of WMIC...
>
>:/>wmic logicaldisk where drivetype=3 get name, freespace, systemname,
>filesystem, size, volumeserialnumber
>
>you can change the drivetype value:
>0 Unknown
>1 No Root Directory
>2 Removable Disk
>3 Local Disk
>4 Network Drive
>5 Compact Disc
>6 RAM Disk
>
>You can lookup win32_logicaldisk to get the other properties and methods
>
>
>> hello!,
>>

>[quoted text clipped - 3 lines]
>>
>> thanks


--
Message posted via WinServerKB.com
http://www.winserverkb.com/Uwe/Forum...pting/200709/1

  Réponse avec citation
Vieux 15/09/2007, 18h34   #3 (permalink)
D.R.
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: read disk serial number with .bat sript

@echo off
setlocal enabledelayedexpansion

fsutil fsinfo drives

set z_list=abcdefghijklmnopqrstuvwxyz

for /l %%a in (0,1,25) do (
set z_drive=!z_list:~%%a,1!
call :check-drive !z_drive!
)

echo+
echo S/N of C is: !z_sn_c!

echo+
pause
exit /b


:check-drive
for /f "tokens=1,2,3" %%a in ('fsutil fsinfo drivetype %~1:\') do (
if /i "%%c"=="fixed" call :getsn %~1
)
goto :eof


:getsn
for /f "tokens=1,2,3,4,5 skip=1" %%a in ('fsutil fsinfo volumeinfo %~1:\')
do (
if /i "%%a %%b %%c"=="Volume Serial Number" (
echo %~1:\ %%e
set z_sn_%~1=%%e
)
)
goto :eof


  Réponse avec citation
Vieux 15/09/2007, 20h10   #4 (permalink)
bvb47 via WinServerKB.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: read disk serial number with .bat sript

Great!,

thanks very much!, its what I was looking for.


D.R. wrote:
>@echo off
>setlocal enabledelayedexpansion
>
>fsutil fsinfo drives
>
>set z_list=abcdefghijklmnopqrstuvwxyz
>
>for /l %%a in (0,1,25) do (
> set z_drive=!z_list:~%%a,1!
> call :check-drive !z_drive!
>)
>
>echo+
>echo S/N of C is: !z_sn_c!
>
>echo+
>pause
>exit /b
>
>:check-drive
>for /f "tokens=1,2,3" %%a in ('fsutil fsinfo drivetype %~1:\') do (
> if /i "%%c"=="fixed" call :getsn %~1
>)
>goto :eof
>
>:getsn
>for /f "tokens=1,2,3,4,5 skip=1" %%a in ('fsutil fsinfo volumeinfo %~1:\')
>do (
> if /i "%%a %%b %%c"=="Volume Serial Number" (
> echo %~1:\ %%e
> set z_sn_%~1=%%e
> )
>)
>goto :eof


--
Message posted via http://www.winserverkb.com

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 03h47.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,08430 seconds with 12 queries