PC Review


Reply
Thread Tools Rate Thread

Converting Filesystem trough VBScript not working

 
 
shatztal
Guest
Posts: n/a
 
      15th Sep 2009
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

 
Reply With Quote
 
 
 
 
Pegasus [MVP]
Guest
Posts: n/a
 
      15th Sep 2009

"shatztal" <(E-Mail Removed)> wrote in message
news:5084E647-4A4D-4E2D-93E2-(E-Mail Removed)...
> 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.


 
Reply With Quote
 
shatztal
Guest
Posts: n/a
 
      15th Sep 2009
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


"Pegasus [MVP]" wrote:

>
> "shatztal" <(E-Mail Removed)> wrote in message
> news:5084E647-4A4D-4E2D-93E2-(E-Mail Removed)...
> > 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.
>
>
>

 
Reply With Quote
 
http://books.google.com/books?id=ifqnAAAACAAJ&dq=i
Guest
Posts: n/a
 
      15th Sep 2009
On 15 Wrz, 09:43, shatztal <shatz...@discussions.microsoft.com> wrote:
> 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
>
>
>
> "Pegasus [MVP]" wrote:
>
> > "shatztal" <shatz...@discussions.microsoft.com> wrote in message
> >news:5084E647-4A4D-4E2D-93E2-(E-Mail Removed)...
> > > 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 commanddoes
> > > 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 nota
> > 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.


 
Reply With Quote
 
http://books.google.com/books?id=ifqnAAAACAAJ&dq=i
Guest
Posts: n/a
 
      15th Sep 2009
On 15 Wrz, 09:29, "Pegasus [MVP]" <n...@microsoft.com> wrote:
> "shatztal" <shatz...@discussions.microsoft.com> wrote in message
>
> news:5084E647-4A4D-4E2D-93E2-(E-Mail Removed)...
>
>
>
>
>
> > 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.


 
Reply With Quote
 
http://books.google.com/books?id=ifqnAAAACAAJ&dq=i
Guest
Posts: n/a
 
      15th Sep 2009
On 15 Wrz, 09:29, "Pegasus [MVP]" <n...@microsoft.com> wrote:
> "shatztal" <shatz...@discussions.microsoft.com> wrote in message
>
> news:5084E647-4A4D-4E2D-93E2-(E-Mail Removed)...
>
>
>
>
>
> > 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.


 
Reply With Quote
 
http://books.google.com/books?id=ifqnAAAACAAJ&dq=i
Guest
Posts: n/a
 
      15th Sep 2009
On 15 Wrz, 09:29, "Pegasus [MVP]" <n...@microsoft.com> wrote:
> "shatztal" <shatz...@discussions.microsoft.com> wrote in message
>
> news:5084E647-4A4D-4E2D-93E2-(E-Mail Removed)...
>
>
>
>
>
> > 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.


 
Reply With Quote
 
http://books.google.com/books?id=ifqnAAAACAAJ&dq=i
Guest
Posts: n/a
 
      15th Sep 2009
On 15 Wrz, 09:43, shatztal <shatz...@discussions.microsoft.com> wrote:
> 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"Pegasus [MVP]" wrote:
>
> > "shatztal" <shatz...@discussions.microsoft.com> wrote in message
> >news:5084E647-4A4D-4E2D-93E2-(E-Mail Removed)...
> > > 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 commanddoes
> > > 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 nota
> > 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.


 
Reply With Quote
 
John John - MVP
Guest
Posts: n/a
 
      15th Sep 2009
shatztal wrote:
> 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
 
Reply With Quote
 
shatztal
Guest
Posts: n/a
 
      15th Sep 2009
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

"http://books.google.com/books?id=ifqnAAA" wrote:

> On 15 Wrz, 09:03, shatztal <shatz...@discussions.microsoft.com> wrote:
> > 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

>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Converting Filesystem trough VBScript not working http://books.google.com/books?id=ifqnAAAACAAJ&dq=i Windows XP General 0 15th Sep 2009 12:54 PM
Converting a VB Function to VBScript Mark Milliman Microsoft Outlook VBA Programming 5 14th Sep 2005 08:42 PM
Converting VBScript command into .NET hien_tran@ghc-hmo.com Microsoft VB .NET 0 3rd Aug 2005 04:32 PM
Re: Converting a VBScript application to VB.NET chanmm Microsoft VB .NET 0 10th Feb 2005 01:35 PM
Problem converting VBScript to VBA Tod Microsoft Excel Programming 0 21st Aug 2003 04:20 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:47 AM.