From: xmd on 11 Aug 2010 00:58 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?
From: Pegasus [MVP] on 11 Aug 2010 02:13 "xmd" <fwdsd45(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.
From: xmd on 11 Aug 2010 02:25 On Aug 11, 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
From: Tom Lavedas on 11 Aug 2010 08:06 On Aug 11, 2:25 am, xmd <fwds...(a)gmail.com> wrote: > On Aug 11, 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
From: Pegasus [MVP] on 11 Aug 2010 13:23
"Tom Lavedas" <tglbatch(a)verizon.net> wrote in message news:9f0e451e-d67c-4df7-b684-0528376555c9(a)t2g2000yqe.googlegroups.com... > On Aug 11, 2:25 am, xmd <fwds...(a)gmail.com> wrote: >> On Aug 11, 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 Ahh, *toogle* was the missing word, not *combine*. Would you send me a link to your on-line post interpreter, please? :-) |