Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script not existing

Status
Not open for further replies.

MoshiachNow

IS-IT--Management
Feb 6, 2002
1,851
0
0
IL
Hi,

I have the following 2 scripts as part of my HTML:

<script language=VBScript>
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set Shell = CreateObject("WScript.Shell")
DesktopPath = Shell.SpecialFolders("Desktop")
File2 = (DesktopPath & "\PE2800_20070110__sys.zip")

if objFSO.FileExists (File2) then
set objShell=CreateObject("Wscript.Shell")
objShell.Run("""%ProgramFiles%\WinZip\winzip32.exe"" -e -o

""%userprofile%\Desktop\PE2800_20070110__sys.zip"" c:\TEMP")
end if
</script>

<script language=VBScript>
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set Shell = CreateObject("WScript.Shell")
DesktopPath = Shell.SpecialFolders("Desktop")
File2 = (DesktopPath & "\PE2800_20070110__sys.zip")
ProgramFiles= Shell.SpecialFolders("ProgramFiles")
File1 = (ProgramFiles & "\WinZip\winzip32.exe")
if objFSO.FileExists (File1) then
Wscript.Quit
elseif objFSO.FileExists (File2) then
set objShell=CreateObject("Wscript.Shell")
objShell.Run("unzip -o ""%userprofile%\Desktop\PE2800_20070110__sys.zip"" -d c:\TEMP")
end if
</script>


I want the second script to skip running "unzip" if the winzip32.exe exists.
However it runs both - unzip and winzip32.
What s wrong >
Thanks

Long live king Moshiach !
 
Why do you need two scripts if they're doing essentially the same thing?

My first guess on the second one is that the ProgramFiles variable is being filled with the path but then when you concatenate the File1 path you're adding a backslash that might already be there. Try writing out the File1 path and see if it's correct of it maybe looks like ...Program Files\\WinZip\winzip32.exe

Since you're not destroying your first Shell object you also probably don't need to create another WScript.Shell object called objShell if the elseif condition is met, you can just use Shell.Run

Hope this helps
 
Part of your problem may be that you are trying to use Wscript.Quit to stop processing your code if winzip32.exe exists, but this does not work in HTML. I would suggest that you put them into functions and if your criteria is met, exit the function or sub.

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top