From: xmd on 11 Aug 2010 22:59 On Aug 11, 8:06 am, Tom Lavedas <tglba...(a)verizon.net> wrote: > OnAug11, 2:25 am, xmd <fwds...(a)gmail.com> wrote: > > > > > > > OnAug11, 2:13 am, "Pegasus [MVP]" <n...(a)microsoft.com> wrote: > > > > "xmd" <fwds...(a)gmail.com> wrote in message > > > >news:dcba46df-b0ac-475f-b4fc-8c4ef78b56a3(a)q22g2000yqm.googlegroups.com.... > > > > > on.vbs: > > > > Dim fsoSet > > > > Set fso = CreateObject("Scripting.FileSystemObject") > > > > fso.MoveFile "c:\windows\system32\drivers\etc\POSTS", "c:\windows > > > > \system32\drivers\etc\HOSTS" > > > > > off.vbs: > > > > Dim fsoSet > > > > Set fso = CreateObject("Scripting.FileSystemObject") > > > > fso.MoveFile "c:\windows\system32\drivers\etc\HOSTS", "c:\windows > > > > \system32\drivers\etc\POSTS" > > > > > how do i combine this 2 vbs into 1? > > > > Combining the two scripts make no sense but here you go: > > > > Set fso = CreateObject("Scripting.FileSystemObject") > > > fso.MoveFile "c:\windows\system32\drivers\etc\POSTS", > > > "c:\windows\system32\drivers\etc\HOSTS" > > > fso.MoveFile "c:\windows\system32\drivers\etc\HOSTS", > > > "c:\windows\system32\drivers\etc\POSTS" > > > > You will also run into trouble because of this documented behaviour: > > > - If destination does not exist, the file gets moved. This is the usual > > > case. > > > - If destination is an existing file, an error occurs. > > > - If destination is a directory, an error occurs. > > > u are right it doesnt work like i want it, I just want a one click > > script to enable/disable the HOST file > > I think you confused Pegasus with the lack of explanation of what you > hoped to achieve. It is possible to create one script that toggles > the name of the file, but that need was not obvious from your initial > request. Try something like this ... > > set sPath = "c:\windows\system32\drivers\etc\" > with CreateObject("Scripting.FileSystemObject") > if .fileexists(sPath & "POSTS") then > .MoveFile sPath & "POSTS", sPath & "HOSTS" > elseif .fileexists(sPath & "HOSTS") then > .MoveFile sPath & "HOSTS", sPath & "POSTS" > else > msgbox "Could find HOST or POST file.", vbOkay & vbExclamation, > "ERROR" > end if > end with > _____________________ > Tom Lavedas im getting an error : Object Required:string... see picture ( http://files.myopera.com/mks523/files/2010-08-11_225241.jpg )
From: Tom Lavedas on 12 Aug 2010 08:28 On Aug 11, 10:59 pm, xmd <fwds...(a)gmail.com> wrote: > On Aug 11, 8:06 am, Tom Lavedas <tglba...(a)verizon.net> wrote: > > > > > OnAug11, 2:25 am, xmd <fwds...(a)gmail.com> wrote: > > > > OnAug11, 2:13 am, "Pegasus [MVP]" <n...(a)microsoft.com> wrote: > > > > > "xmd" <fwds...(a)gmail.com> wrote in message > > > > >news:dcba46df-b0ac-475f-b4fc-8c4ef78b56a3(a)q22g2000yqm.googlegroups.com... > > > > > > on.vbs: > > > > > Dim fsoSet > > > > > Set fso = CreateObject("Scripting.FileSystemObject") > > > > > fso.MoveFile "c:\windows\system32\drivers\etc\POSTS", "c:\windows > > > > > \system32\drivers\etc\HOSTS" > > > > > > off.vbs: > > > > > Dim fsoSet > > > > > Set fso = CreateObject("Scripting.FileSystemObject") > > > > > fso.MoveFile "c:\windows\system32\drivers\etc\HOSTS", "c:\windows > > > > > \system32\drivers\etc\POSTS" > > > > > > how do i combine this 2 vbs into 1? > > > > > Combining the two scripts make no sense but here you go: > > > > > Set fso = CreateObject("Scripting.FileSystemObject") > > > > fso.MoveFile "c:\windows\system32\drivers\etc\POSTS", > > > > "c:\windows\system32\drivers\etc\HOSTS" > > > > fso.MoveFile "c:\windows\system32\drivers\etc\HOSTS", > > > > "c:\windows\system32\drivers\etc\POSTS" > > > > > You will also run into trouble because of this documented behaviour: > > > > - If destination does not exist, the file gets moved. This is the usual > > > > case. > > > > - If destination is an existing file, an error occurs. > > > > - If destination is a directory, an error occurs. > > > > u are right it doesnt work like i want it, I just want a one click > > > script to enable/disable the HOST file > > > I think you confused Pegasus with the lack of explanation of what you > > hoped to achieve. It is possible to create one script that toggles > > the name of the file, but that need was not obvious from your initial > > request. Try something like this ... > > > set sPath = "c:\windows\system32\drivers\etc\" > > with CreateObject("Scripting.FileSystemObject") > > if .fileexists(sPath & "POSTS") then > > .MoveFile sPath & "POSTS", sPath & "HOSTS" > > elseif .fileexists(sPath & "HOSTS") then > > .MoveFile sPath & "HOSTS", sPath & "POSTS" > > else > > msgbox "Could find HOST or POST file.", vbOkay & vbExclamation, > > "ERROR" > > end if > > end with > > _____________________ > > Tom Lavedas > > im getting an error : Object Required:string... see picture (http://files..myopera.com/mks523/files/2010-08-11_225241.jpg) I get "Error 503 Service Unavailable" when trying to follow that link. Sorry, stupid error. Take the word 'set' off of the first line. _____________________ Tom Lavedas
From: xmd on 12 Aug 2010 20:12
On Aug 12, 8:28 am, Tom Lavedas <tglba...(a)verizon.net> wrote: > OnAug11, 10:59 pm, xmd <fwds...(a)gmail.com> wrote: > > > > > > > OnAug11, 8:06 am, Tom Lavedas <tglba...(a)verizon.net> wrote: > > > > OnAug11, 2:25 am, xmd <fwds...(a)gmail.com> wrote: > > > > > OnAug11, 2:13 am, "Pegasus [MVP]" <n...(a)microsoft.com> wrote: > > > > > > "xmd" <fwds...(a)gmail.com> wrote in message > > > > > >news:dcba46df-b0ac-475f-b4fc-8c4ef78b56a3(a)q22g2000yqm.googlegroups..com... > > > > > > > on.vbs: > > > > > > Dim fsoSet > > > > > > Set fso = CreateObject("Scripting.FileSystemObject") > > > > > > fso.MoveFile "c:\windows\system32\drivers\etc\POSTS", "c:\windows > > > > > > \system32\drivers\etc\HOSTS" > > > > > > > off.vbs: > > > > > > Dim fsoSet > > > > > > Set fso = CreateObject("Scripting.FileSystemObject") > > > > > > fso.MoveFile "c:\windows\system32\drivers\etc\HOSTS", "c:\windows > > > > > > \system32\drivers\etc\POSTS" > > > > > > > how do i combine this 2 vbs into 1? > > > > > > Combining the two scripts make no sense but here you go: > > > > > > Set fso = CreateObject("Scripting.FileSystemObject") > > > > > fso.MoveFile "c:\windows\system32\drivers\etc\POSTS", > > > > > "c:\windows\system32\drivers\etc\HOSTS" > > > > > fso.MoveFile "c:\windows\system32\drivers\etc\HOSTS", > > > > > "c:\windows\system32\drivers\etc\POSTS" > > > > > > You will also run into trouble because of this documented behaviour: > > > > > - If destination does not exist, the file gets moved. This is the usual > > > > > case. > > > > > - If destination is an existing file, an error occurs. > > > > > - If destination is a directory, an error occurs. > > > > > u are right it doesnt work like i want it, I just want a one click > > > > script to enable/disable the HOST file > > > > I think you confused Pegasus with the lack of explanation of what you > > > hoped to achieve. It is possible to create one script that toggles > > > the name of the file, but that need was not obvious from your initial > > > request. Try something like this ... > > > > set sPath = "c:\windows\system32\drivers\etc\" > > > with CreateObject("Scripting.FileSystemObject") > > > if .fileexists(sPath & "POSTS") then > > > .MoveFile sPath & "POSTS", sPath & "HOSTS" > > > elseif .fileexists(sPath & "HOSTS") then > > > .MoveFile sPath & "HOSTS", sPath & "POSTS" > > > else > > > msgbox "Could find HOST or POST file.", vbOkay & vbExclamation, > > > "ERROR" > > > end if > > > end with > > > _____________________ > > > Tom Lavedas > > > im getting an error : Object Required:string... see picture (http://files.myopera.com/mks523/files/2010-08-11_225241.jpg) > > I get "Error 503 Service Unavailable" when trying to follow that link. > > Sorry, stupid error. Take the word 'set' off of the first line. > _____________________ > Tom Lavedas Thanks. Have a great day. |