Need some script help.

From Visual Basic to GNU C, this is the place to talk programming.

Moderators: SecretSquirrel, just brew it!

Need some script help.

Postposted on Mon Mar 17, 2003 8:25 pm

I have a couple of scripts that turn off and on flash by renaming the file. It would be nice to be able to have just one script that would look to see what the file is currently named then rename it accordingly. Here is the current scripts.

Flash Off.
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.MoveFile "C:\WINDOWS\system32\Macromed\Flash\Flash.ocx" , "C:\WINDOWS\system32\Macromed\Flash\offFlash.ocx"

objFSO.MoveFile "C:\WINDOWS\system32\Macromed\Flash\swFlash.ocx" , "C:\WINDOWS\system32\Macromed\Flash\offswFlash.ocx"


Flash On.
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.MoveFile "C:\WINDOWS\system32\Macromed\Flash\offFlash.ocx" , "C:\WINDOWS\system32\Macromed\Flash\Flash.ocx"

objFSO.MoveFile "C:\WINDOWS\system32\Macromed\Flash\offswFlash.ocx" , "C:\WINDOWS\system32\Macromed\Flash\swFlash.ocx"


I'm using *.vbs file.
I'm thinking I may need to search the folder then use some sort of "if" to reduce these down to just one script. I'm not sure. Anybody help with this?

Thanks.
newbie_of_jan0502
Gerbil Jedi
 
Posts: 1770
Joined: Fri Jan 04, 2002 6:00 pm
Location: Houston, TX

Postposted on Sat Apr 05, 2003 8:34 pm

Im not too good with flash, but couldnt you use an if to test for "flash.ocx"

If it exists then
turn flash off
else
turn flash on
end if
Windows XP - The 64-bit wannabe with a 32-bit graphics interface for 16-bit extensions to a 8-bit patch on a 4-bit operating system designed to run on a 2-bit processor by a company that can't stand 1-bit of competition
fc34
Minister of Gerbil Affairs
 
Posts: 2816
Joined: Wed May 08, 2002 7:39 am
Location: Somewhere

Postposted on Wed Apr 23, 2003 3:52 am

There's a FileExists method on the FileSystemObject object. Shouldn't be too hard to use that in conjunction with the MoveFile method you are using already.

Code: Select all
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists("C:\WINDOWS\system32\Macromed\Flash\Flash.ocx") Then
    objFSO.MoveFile "C:\WINDOWS\system32\Macromed\Flash\Flash.ocx" , "C:\WINDOWS\system32\Macromed\Flash\offFlash.ocx"
Else
    objFSO.MoveFile "C:\WINDOWS\system32\Macromed\Flash\offFlash.ocx" , "C:\WINDOWS\system32\Macromed\Flash\Flash.ocx"
End If


It assumes a fair bit in terms of the files that exist, but that should work as a simple toggle. You could make it safer and add some status reporting but that's a core to work from.

Apologies if the syntax is wrong, I'm coding off the top of my head and haven't checked it.

Rys
Ryszard
Gerbil
Gold subscriber
 
 
Posts: 28
Joined: Sat Apr 27, 2002 9:15 pm


Return to Developer's Den

Who is online

Users browsing this forum: No registered users and 1 guest