Hi, Dear all, i wrote below script, i want to convert remote host Harddisk
format from FAT32 to NTFS, it 's failed in remote hosts, but succeed in
local host. would you please check it for me ? with many thanks !

Regards.
Michael
************************************************************************************************************************
Const Fixed = 2
Const ForReading = 1
Set objOFSO = CreateObject("Scripting.FileSystemObject")
Set oShell = Wscript.CreateObject("WScript.Shell")
Set objTextFile = objOFSO.OpenTextFile("c:\myscript\list.txt",ForReading)
sFile = objOFSO.GetSpecialFolder(2).ShortPath & "\" & objOFSO.GetTempName
ON Error Resume Next
Do while Not objTextFile.AtEndOfStream
strComputer = objTextFile.ReadLine
Set objWMIService = GetObject("winmgmts://"&strComputer)
'Set colLogicalDisk = objWMIService.Instancesof("win32_LogicalDisk")
set colLogicalDisk = objWMIService.ExecQuery("select * from
Win32_LogicalDisk where DriveType= 2")
For Each objLOgicalDisk In colLogicalDisk
IF UCase(ObjLogicalDisk.FileSystem) = "FAT32" Then
sDiskLetter = obiLogicalDisk.DriveLetter
sDiskLabel = objLOgicalDisk.VolumeName
If sDiskLabel = "" Then
sCmd = "%comspec% /c echo y|convert.exe " & sDiskLetter & ":
/fs:ntfs"
Else
Set fFile = objOFSO.CreateTextFile(sFile)
fFile.WriteLine sDiskLabel
fFile.WriteLine "y"
fFile.Close
sCmd = "%comspec% /c convert.exe " & sDiskLetter & ": /fs:ntfs <"&
sFile
End If
oShell.Run sCmd, 0, True
End If
Next
Loop

RE: convert FAT32 to NTFS problem? by roopeman

roopeman
Fri Nov 04 03:22:02 CST 2005

below is the update version after check MSDN, but still not work even in
local system,anybody can help me ?!
*********************
Const Fixed = 12
Const ForReading = 1
Set objOFSO = CreateObject("Scripting.FileSystemObject")
Set oShell = Wscript.CreateObject("WScript.Shell")
Set objTextFile = objOFSO.OpenTextFile("c:\myscript\list.txt",ForReading)
sFile = objOFSO.GetSpecialFolder(2).ShortPath & "\" & objOFSO.GetTempName
ON Error Resume Next
Do while Not objTextFile.AtEndOfStream
strComputer = objTextFile.ReadLine
Set objWMIService = GetObject("winmgmts://"&strComputer)
'Set colLogicalDisk = objWMIService.Instancesof("win32_LogicalDisk")
set colLogicalDisk = objWMIService.ExecQuery("select * from
Win32_LogicalDisk where MediaType= 12")
For Each objLOgicalDisk In colLogicalDisk
IF UCase(ObjLogicalDisk.FileSystem) = "FAT32" Then
sDiskLetter = obiLogicalDisk.DiskID
sDiskLabel = objLOgicalDisk.VolumeName
If sDiskLabel = "" Then
sCmd = "%comspec% /c echo y|convert.exe " & sDiskLetter & "
/fs:ntfs"
Else
Set fFile = objOFSO.CreateTextFile(sFile)
fFile.WriteLine sDiskLabel
fFile.WriteLine "y"
fFile.Close
sCmd = "%comspec% /c convert.exe " & sDiskLetter & " /fs:ntfs <"&
sFile
End If

oShell.Run sCmd, 0, True
Wscript.Echo"Run or not?"

End If
Next
Loop

****************************************

"roopeman" wrote:

> Hi, Dear all, i wrote below script, i want to convert remote host Harddisk
> format from FAT32 to NTFS, it 's failed in remote hosts, but succeed in
> local host. would you please check it for me ? with many thanks !
>
> Regards.
> Michael
> ************************************************************************************************************************
> Const Fixed = 2
> Const ForReading = 1
> Set objOFSO = CreateObject("Scripting.FileSystemObject")
> Set oShell = Wscript.CreateObject("WScript.Shell")
> Set objTextFile = objOFSO.OpenTextFile("c:\myscript\list.txt",ForReading)
> sFile = objOFSO.GetSpecialFolder(2).ShortPath & "\" & objOFSO.GetTempName
> ON Error Resume Next
> Do while Not objTextFile.AtEndOfStream
> strComputer = objTextFile.ReadLine
> Set objWMIService = GetObject("winmgmts://"&strComputer)
> 'Set colLogicalDisk = objWMIService.Instancesof("win32_LogicalDisk")
> set colLogicalDisk = objWMIService.ExecQuery("select * from
> Win32_LogicalDisk where DriveType= 2")
> For Each objLOgicalDisk In colLogicalDisk
> IF UCase(ObjLogicalDisk.FileSystem) = "FAT32" Then
> sDiskLetter = obiLogicalDisk.DriveLetter
> sDiskLabel = objLOgicalDisk.VolumeName
> If sDiskLabel = "" Then
> sCmd = "%comspec% /c echo y|convert.exe " & sDiskLetter & ":
> /fs:ntfs"
> Else
> Set fFile = objOFSO.CreateTextFile(sFile)
> fFile.WriteLine sDiskLabel
> fFile.WriteLine "y"
> fFile.Close
> sCmd = "%comspec% /c convert.exe " & sDiskLetter & ": /fs:ntfs <"&
> sFile
> End If
> oShell.Run sCmd, 0, True
> End If
> Next
> Loop
>

Re: convert FAT32 to NTFS problem? by Marty

Marty
Fri Nov 04 06:46:34 CST 2005


"roopeman" <roopeman@discussions.microsoft.com> wrote in message
news:8109585A-A94E-4A3F-B691-5DBBC6092944@microsoft.com...
>> Hi, Dear all, i wrote below script, i want to convert remote host
>> Harddisk
>> format from FAT32 to NTFS, it 's failed in remote hosts, but succeed in
>> local host. would you please check it for me ? with many thanks !

Your script is always launching convert.exe on the local machine. The
script connects to the remote computer using WMI, and gets the drives of the
remote computer, but launches convert.exe onthe local system, with the
remote systems's drive letter.

Your script uses oShell.Run to launch convert.exe, but look at where oShell
comes from:
Set oShell = Wscript.CreateObject("WScript.Shell")
So when you call the .Run method, how is it suppose to know you want it
launched on the remote system?

Try WMI's Win32_Process.Create method, which can be used against a remote
system:
http://msdn.microsoft.com/library/en-us/wmisdk/wmi/win32_process.asp
http://msdn.microsoft.com/library/en-us/wmisdk/wmi/create_method_in_class_win32_process.asp




Re: convert FAT32 to NTFS problem? by roopeman

roopeman
Sat Nov 05 02:22:01 CST 2005

Hi,Marty List, you mean as below,it 's not work also, and i can not found
more info. about Win32_process.create in MSDN,can you help me !?

strComputer = "host001"
Set objWMIService = GetObject _
("winmgmts:\\" & strComputer & "\root\cimv2:Win32_Process")

Error = objWMIService.Create("c:\windows\system32\convert.exe d:/FS:NTFS",
null, null, intProcessID)

If Error = 0 Then
Wscript.Echo "Notepad was started with a process ID of " _
& intProcessID & "."
Else
Wscript.Echo "Notepad could not be started due to error " & _
Error & "."
End If

"Marty List" wrote:

>
> "roopeman" <roopeman@discussions.microsoft.com> wrote in message
> news:8109585A-A94E-4A3F-B691-5DBBC6092944@microsoft.com...
> >> Hi, Dear all, i wrote below script, i want to convert remote host
> >> Harddisk
> >> format from FAT32 to NTFS, it 's failed in remote hosts, but succeed in
> >> local host. would you please check it for me ? with many thanks !
>
> Your script is always launching convert.exe on the local machine. The
> script connects to the remote computer using WMI, and gets the drives of the
> remote computer, but launches convert.exe onthe local system, with the
> remote systems's drive letter.
>
> Your script uses oShell.Run to launch convert.exe, but look at where oShell
> comes from:
> Set oShell = Wscript.CreateObject("WScript.Shell")
> So when you call the .Run method, how is it suppose to know you want it
> launched on the remote system?
>
> Try WMI's Win32_Process.Create method, which can be used against a remote
> system:
> http://msdn.microsoft.com/library/en-us/wmisdk/wmi/win32_process.asp
> http://msdn.microsoft.com/library/en-us/wmisdk/wmi/create_method_in_class_win32_process.asp
>
>
>
>

Re: convert FAT32 to NTFS problem? by roopeman

roopeman
Sat Nov 05 04:48:02 CST 2005

Hi, Marty List, i modified my script as below, pls. check it for me, thanks !
************************************************************
Const Fixed = 12
Const ForReading = 1
Set objOFSO = CreateObject("Scripting.FileSystemObject")
'Set oShell = Wscript.CreateObject("WScript.Shell")
Set objTextFile = objOFSO.OpenTextFile("c:\myscript\list.txt",ForReading)
'sFile = objOFSO.GetSpecialFolder(2).ShortPath & "\" & objOFSO.GetTempName
ON Error Resume Next
Do while Not objTextFile.AtEndOfStream
strComputer = objTextFile.ReadLine
Set objWMIService = GetObject("winmgmts://"&strComputer)
'Set colLogicalDisk = objWMIService.Instancesof("win32_LogicalDisk")
set colLogicalDisk = objWMIService.ExecQuery("select * from
Win32_LogicalDisk where MediaType= 12")
For Each objLOgicalDisk In colLogicalDisk
IF UCase(ObjLogicalDisk.FileSystem) = "FAT32" Then
sDiskLetter = obiLogicalDisk.DiskID
sDiskLabel = objLOgicalDisk.VolumeName
If sDiskLabel = "" Then
set objWMIService2 = GetObject("winmgmts:\\"&strComputer&
"\root\cimv2:win32_process")
objWMIservice.Create("cmd.exe /c
convert.exe"&sDiskLetter&":/fs:ntfs")
set objWMIService2 = NOthing
Else
sDiskLable = Null
set objWMIService2 = GetObject("winmgmts:\\"&strComputer&
"\root\cimv2:win32_process")
objWMIservice.Create("cmd.exe /c
convert.exe"&sDiskLetter&":/fs:ntfs")
End If


End If
Next
Loop

************************************************************


"roopeman" wrote:

> Hi,Marty List, you mean as below,it 's not work also, and i can not found
> more info. about Win32_process.create in MSDN,can you help me !?
>
> strComputer = "host001"
> Set objWMIService = GetObject _
> ("winmgmts:\\" & strComputer & "\root\cimv2:Win32_Process")
>
> Error = objWMIService.Create("c:\windows\system32\convert.exe d:/FS:NTFS",
> null, null, intProcessID)
>
> If Error = 0 Then
> Wscript.Echo "Notepad was started with a process ID of " _
> & intProcessID & "."
> Else
> Wscript.Echo "Notepad could not be started due to error " & _
> Error & "."
> End If
>
> "Marty List" wrote:
>
> >
> > "roopeman" <roopeman@discussions.microsoft.com> wrote in message
> > news:8109585A-A94E-4A3F-B691-5DBBC6092944@microsoft.com...
> > >> Hi, Dear all, i wrote below script, i want to convert remote host
> > >> Harddisk
> > >> format from FAT32 to NTFS, it 's failed in remote hosts, but succeed in
> > >> local host. would you please check it for me ? with many thanks !
> >
> > Your script is always launching convert.exe on the local machine. The
> > script connects to the remote computer using WMI, and gets the drives of the
> > remote computer, but launches convert.exe onthe local system, with the
> > remote systems's drive letter.
> >
> > Your script uses oShell.Run to launch convert.exe, but look at where oShell
> > comes from:
> > Set oShell = Wscript.CreateObject("WScript.Shell")
> > So when you call the .Run method, how is it suppose to know you want it
> > launched on the remote system?
> >
> > Try WMI's Win32_Process.Create method, which can be used against a remote
> > system:
> > http://msdn.microsoft.com/library/en-us/wmisdk/wmi/win32_process.asp
> > http://msdn.microsoft.com/library/en-us/wmisdk/wmi/create_method_in_class_win32_process.asp
> >
> >
> >
> >

Re: convert FAT32 to NTFS problem? by roopeman

roopeman
Mon Nov 07 01:58:04 CST 2005

this is my last version, anybody can check it for me ? thanks !

Const Fixed = 12
Const ForReading = 1
Set objOFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objOFSO.OpenTextFile("c:\myscript\list.txt",ForReading)
ON Error Resume Next
Do while Not objTextFile.AtEndOfStream
strComputer = objTextFile.ReadLine
Set objWMIService = GetObject("winmgmts://"&strComputer)
set colLogicalDisk = objWMIService.ExecQuery("select * from
Win32_LogicalDisk where MediaType= 12")
For Each objLOgicalDisk In colLogicalDisk
IF UCase(ObjLogicalDisk.FileSystem) = "FAT32" Then
sDiskLetter = obiLogicalDisk.DeviceID
sDiskLabel = objLOgicalDisk.VolumeName
If sDiskLabel = "" Then
set objWMIService2 = GetObject("winmgmts:\\"&strComputer&
"\root\cimv2:win32_process")
objWMIservice.Create("cmd.exe /c
convert.exe"&sDiskLetter&":/fs:ntfs")
set objWMIService2 = NOthing
Else
sDiskLable = ""
sDiskLable.Put_
set objWMIService2 = GetObject("winmgmts:\\"&strComputer&
"\root\cimv2:win32_process")
objWMIservice.Create("cmd.exe /c
convert.exe"&sDiskLetter&":/fs:ntfs")
End If


End If
Next
Loop





"roopeman" wrote:

> Hi, Marty List, i modified my script as below, pls. check it for me, thanks !
> ************************************************************
> Const Fixed = 12
> Const ForReading = 1
> Set objOFSO = CreateObject("Scripting.FileSystemObject")
> 'Set oShell = Wscript.CreateObject("WScript.Shell")
> Set objTextFile = objOFSO.OpenTextFile("c:\myscript\list.txt",ForReading)
> 'sFile = objOFSO.GetSpecialFolder(2).ShortPath & "\" & objOFSO.GetTempName
> ON Error Resume Next
> Do while Not objTextFile.AtEndOfStream
> strComputer = objTextFile.ReadLine
> Set objWMIService = GetObject("winmgmts://"&strComputer)
> 'Set colLogicalDisk = objWMIService.Instancesof("win32_LogicalDisk")
> set colLogicalDisk = objWMIService.ExecQuery("select * from
> Win32_LogicalDisk where MediaType= 12")
> For Each objLOgicalDisk In colLogicalDisk
> IF UCase(ObjLogicalDisk.FileSystem) = "FAT32" Then
> sDiskLetter = obiLogicalDisk.DiskID
> sDiskLabel = objLOgicalDisk.VolumeName
> If sDiskLabel = "" Then
> set objWMIService2 = GetObject("winmgmts:\\"&strComputer&
> "\root\cimv2:win32_process")
> objWMIservice.Create("cmd.exe /c
> convert.exe"&sDiskLetter&":/fs:ntfs")
> set objWMIService2 = NOthing
> Else
> sDiskLable = Null
> set objWMIService2 = GetObject("winmgmts:\\"&strComputer&
> "\root\cimv2:win32_process")
> objWMIservice.Create("cmd.exe /c
> convert.exe"&sDiskLetter&":/fs:ntfs")
> End If
>
>
> End If
> Next
> Loop
>
> ************************************************************
>
>
> "roopeman" wrote:
>
> > Hi,Marty List, you mean as below,it 's not work also, and i can not found
> > more info. about Win32_process.create in MSDN,can you help me !?
> >
> > strComputer = "host001"
> > Set objWMIService = GetObject _
> > ("winmgmts:\\" & strComputer & "\root\cimv2:Win32_Process")
> >
> > Error = objWMIService.Create("c:\windows\system32\convert.exe d:/FS:NTFS",
> > null, null, intProcessID)
> >
> > If Error = 0 Then
> > Wscript.Echo "Notepad was started with a process ID of " _
> > & intProcessID & "."
> > Else
> > Wscript.Echo "Notepad could not be started due to error " & _
> > Error & "."
> > End If
> >
> > "Marty List" wrote:
> >
> > >
> > > "roopeman" <roopeman@discussions.microsoft.com> wrote in message
> > > news:8109585A-A94E-4A3F-B691-5DBBC6092944@microsoft.com...
> > > >> Hi, Dear all, i wrote below script, i want to convert remote host
> > > >> Harddisk
> > > >> format from FAT32 to NTFS, it 's failed in remote hosts, but succeed in
> > > >> local host. would you please check it for me ? with many thanks !
> > >
> > > Your script is always launching convert.exe on the local machine. The
> > > script connects to the remote computer using WMI, and gets the drives of the
> > > remote computer, but launches convert.exe onthe local system, with the
> > > remote systems's drive letter.
> > >
> > > Your script uses oShell.Run to launch convert.exe, but look at where oShell
> > > comes from:
> > > Set oShell = Wscript.CreateObject("WScript.Shell")
> > > So when you call the .Run method, how is it suppose to know you want it
> > > launched on the remote system?
> > >
> > > Try WMI's Win32_Process.Create method, which can be used against a remote
> > > system:
> > > http://msdn.microsoft.com/library/en-us/wmisdk/wmi/win32_process.asp
> > > http://msdn.microsoft.com/library/en-us/wmisdk/wmi/create_method_in_class_win32_process.asp
> > >
> > >
> > >
> > >

Re: convert FAT32 to NTFS problem? by Marty

Marty
Mon Nov 07 10:21:31 CST 2005


"roopeman" <roopeman@discussions.microsoft.com> wrote in message
news:4E99148D-059A-469E-9563-44DA62996A80@microsoft.com...
> this is my last version, anybody can check it for me ? thanks !


It's a good thing (bad thing?) that VBScript is case insensitive.


This line has a typo:
sDiskLetter = obiLogicalDisk.DiskID


Change *both* instances of this line:
objWMIservice.Create("cmd.exe /c convert.exe"&sDiskLetter&":/fs:ntfs")

to this:
sCommandLine = "cmd.exe /c convert.exe " & sDiskLetter & " /fs:ntfs"
WScript.Echo "DEBUG: " & sCommandLine
objWMIservice2.Create(sCommandLine)


You have two variables with very similar names (objWMIservice and
objWMIservice2). You should choose more descriptive names so you can determine
what they are used for.




Re: convert FAT32 to NTFS problem? by Marty

Marty
Mon Nov 07 10:29:21 CST 2005


I suggest you slow down a little a learn the basics of scripting, start with
read-only operations before jumping in making changes to remote systems (like
converting the file system to NTFS).

Your script needs error checking, and debug statements so you can see what's
going on. Scripting is powerful - but can also be dangerous.

Lots of good books out there, and lots of resources in the TechNet Script
Center:
http://www.microsoft.com/technet/scriptcenter/