I've done a script to install Oracle 11g runtime then apply a patch at the end. It works up until the patching when I get a "The system cannot find the file specified" error at Line 45 Char 1.

Applying the patch with the same lines of code in a separate vbs doesn't produce this problem?

My script is:


Dim oShell, fso, sCurPath, i, varPath, oShell1
Dim objWSH, objUserVariables, objSystemVariables

'On Error Resume Next

Set fso = WScript.Createobject("Scripting.FileSystemObject")
Set oShell = CreateObject("WScript.Shell")

' Install Oracle Client 11g Release 2
sCurPath = CreateObject("Scripting.FileSystemObject").GetAbsolutePathName(".")
sCmdLine = sCurPath + "\Client\setup.exe -waitforcompletion -noconsole -silent -force -responseFile " + sCurPath + "\client\response\Oracle_11g_Release_2_Client_P1.0.rsp"

i = oShell.Run(sCmdLine, 1 ,True)

' Copy the updated Opatch to the installation
fso.CopyFolder sCurPath & "\OPatch", "C:\oracle\product\11.2.0\client_1\", True

' Copy the patch to ORACLE_HOME
fso.CopyFolder sCurPath & "\12429528", "C:\oracle\product\11.2.0\client_1\", True

' Create Opatch log folder
fso.CreateFolder "C:\oracle\product\11.2.0\client_1\cfgtoollogs\opatch"

' Rename oci.dll to allow for patch application
fso.MoveFile "C:\oracle\product\11.2.0\client_1\BIN\oci.dll" , "C:\oracle\product\11.2.0\client_1\BIN\oci.old"

' Set required Environment Variables
Set objWSH = CreateObject("WScript.Shell")
Set objSystemVariables = objWSH.Environment("SYSTEM")
varPath = objSystemVariables("PATH")
objSystemVariables("PATH") = varPath & ";C:\oracle\product\11.2.0\client_1\OPatch"
objSystemVariables("ORACLE_HOME") = "C:\oracle\product\11.2.0\client_1"
objSystemVariables("ORACLE_BASE") = "C:\oracle"

' Apply patch
'WScript.sleep 10000
Set oShell1 = CreateObject("WScript.Shell")
oShell1.CurrentDirectory="C:\oracle\product\11.2.0\client_1\12429528"
oShell1.Run "opatch apply -silent -force -ocmrf C:\oracle\product\11.2.0\client_1\OPatch\ocm.rsp",1,True

WScript.Quit(i)


Can anyone point out what's wrong here?

Thanks
0 Comments   [ + ] Show Comments

Comments

Please log in to comment

Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.

Answers

0
"opatch apply -silent -force -ocmrf C:\oracle\product\11.2.0\client_1\OPatch\ocm.rsp"

This is the name of the file you are about to run.

An easy way to spot these kinds of errors are to store your command line in a variable and run your script with a "MSGBOX variableName" instead of Run, to check if the commandline looks as intended.

/Matias
Answered 10/03/2011 by: Matias M Andersen
Senior Yellow Belt

Please log in to comment
0
Hi Matias,

when I run a script with just these lines of code:


' Apply patch
'WScript.sleep 10000
Set oShell1 = CreateObject("WScript.Shell")
oShell1.CurrentDirectory="C:\oracle\product\11.2.0\client_1\12429528"
oShell1.Run "opatch apply -silent -force -ocmrf C:\oracle\product\11.2.0\client_1\OPatch\ocm.rsp",1,True


it works fine. These have just been copied and pasted from my original script which gives the error?
Answered 10/03/2011 by: tmpamlrs
Senior Yellow Belt

Please log in to comment
0
Having had a dig around it seems that the Environment Variables are set but not available to the running wscript process. There are ways to broadcast the changes with VB but too complex for my needs. I'll stick with a separate script.
Answered 10/04/2011 by: tmpamlrs
Senior Yellow Belt

Please log in to comment
0
As you've probably discovered, VBS sets System environment variables OK, just not for the current session. If you make the environment variables "User" instead of "System", it should work fine.
Answered 10/04/2011 by: VBScab
Red Belt

Please log in to comment
Answer this question or Comment on this question for clarity