Converting Filesystem trough VBScript not working

  • Thread starter Thread starter shatztal
  • Start date Start date
S

shatztal

The Script is in VBscript an should check if the filesystem is not NTFS, if
not it should convert it. this is what i have but the convert command does
not work .

On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set objWMIService2 = GetObject("winmgmts:" &
"{impersonationLevel=impersonate,(Shutdown)}!\\" & _
strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_LogicalDisk
where drivetype ='3'",,48)
Set colOperatingSystems = objWMIService2.ExecQuery("Select * from
Win32_OperatingSystem")
Set WShell = WScript.CreateObject("Wscript.Shell")

wscript.Echo "We Are making now changes"

for each objItem in colItems
' set objItem = colItems.item(0)
FS = objItem.Filesystem
if FS = "NTFS" then
msgbox "מחשבך מוכן לשימוש תקין"
else
Wscript.Echo "Non NTFS Files"
WShell.run "cmd.exe /k |echo y |convert c: /FS:NTFS /X"
msgbox "המחשב יתחיל ב×תחול בעוד ×¨×’×¢×™× ×¡×¤×•×¨×™×"
counter = 15
do while counter > 0
Wscript.echo counter
wscript.sleep 1000
counter = counter -1
loop
msgbox "המחשב מבצע ×תחול"
For Each objOperatingSystem in colOperatingSystems
objOperatingSystem.Reboot()
Next
end if
next
 
shatztal said:
The Script is in VBscript an should check if the filesystem is not NTFS,
if
not it should convert it. this is what i have but the convert command does
not work .

On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set objWMIService2 = GetObject("winmgmts:" &
"{impersonationLevel=impersonate,(Shutdown)}!\\" & _
strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_LogicalDisk
where drivetype ='3'",,48)
Set colOperatingSystems = objWMIService2.ExecQuery("Select * from
Win32_OperatingSystem")
Set WShell = WScript.CreateObject("Wscript.Shell")

wscript.Echo "We Are making now changes"

for each objItem in colItems
' set objItem = colItems.item(0)
FS = objItem.Filesystem
if FS = "NTFS" then
msgbox "????? ???? ?????? ????"
else
Wscript.Echo "Non NTFS Files"
WShell.run "cmd.exe /k |echo y |convert c: /FS:NTFS /X"
msgbox "????? ????? ?????? ???? ????? ??????"
counter = 15
do while counter > 0
Wscript.echo counter
wscript.sleep 1000
counter = counter -1
loop
msgbox "????? ???? ?????"
For Each objOperatingSystem in colOperatingSystems
objOperatingSystem.Reboot()
Next
end if
next

Some comments about your post:
- You should report what happens and what you see when you run the script.
- Having the statement "On error resume next" on top of the code is not a
good idea. It prevents you from seeing errors that might occur.
- The line
WShell.run "cmd.exe /k |echo y |convert c: /FS:NTFS /X"
should probably read
WShell.run "cmd.exe /k |echo y |convert " & objItem.DeviceID & " /FS:NTFS
/X"
- This is a Windows XP newsgroup. For involved scripts like this one, you
should post in a VB Scripting newsgroup.
 
thanks again i will post there
by the way i don't get any erros on the CMD line just that is does not run
 
Some comments about your post:
- You should report what happens and what you see when you run the script..
- Having the statement "On error resume next" on top of the code is not a
good idea. It prevents you from seeing errors that might occur.
- The line
  WShell.run "cmd.exe /k |echo y |convert c: /FS:NTFS /X"
  should probably read
  WShell.run "cmd.exe /k |echo y |convert " & objItem.DeviceID & " /FS:NTFS
/X"
- This is a Windows XP newsgroup. For involved scripts like this one, you
should post in a VB Scripting newsgroup.
 
Some comments about your post:
- You should report what happens and what you see when you run the script..
- Having the statement "On error resume next" on top of the code is not a
good idea. It prevents you from seeing errors that might occur.
- The line
  WShell.run "cmd.exe /k |echo y |convert c: /FS:NTFS /X"
  should probably read
  WShell.run "cmd.exe /k |echo y |convert " & objItem.DeviceID & " /FS:NTFS
/X"
- This is a Windows XP newsgroup. For involved scripts like this one, you
should post in a VB Scripting newsgroup.
 
Some comments about your post:
- You should report what happens and what you see when you run the script..
- Having the statement "On error resume next" on top of the code is not a
good idea. It prevents you from seeing errors that might occur.
- The line
  WShell.run "cmd.exe /k |echo y |convert c: /FS:NTFS /X"
  should probably read
  WShell.run "cmd.exe /k |echo y |convert " & objItem.DeviceID & " /FS:NTFS
/X"
- This is a Windows XP newsgroup. For involved scripts like this one, you
should post in a VB Scripting newsgroup.
 
shatztal said:
thanks again i will post there
by the way i don't get any erros on the CMD line just that is does not run

Your "quotation marks" are not right and I'm not sure why you put the
echo command in there, this is all that you need:

cmd.exe /k convert c: /FS:NTFS /X

John
 
thanks all but what you said didn't help
the first Pipe line wasn't neccesseray
cmd echo y | convert c: /FS:NTFS /X
had done it good without PIPE.

echo y is neede cause you need to confirm the reboot when asked
 
Bill in Co. said:
That's not the only thing that is errant. That From: user name is
errant.

Try clicking the user name and see what happens! I think it's a form of
spam!
 
The /k switch continues the command session so echo would not be
needed... but I see that you now decided to do away with the switch.

John
 
Back
Top