ProjAdminAuto Object

The ProjAdminAuto object can be used to access the information of installed WinCC OA projects in the same ways as ProjAdmin object but the interface can also be used for script languages like vbScript. For the description of the methods see ProjAdmin Object.

Figure 1. Object catalog - ProjAdminAuto Object

You can find an example in the WinCC OA version under source. The example is composed of two files getProj.cmd and getProj.vbs. The VBScript queries the current project and checks the config file. If the script was executed successfully, a temporary batch file with a command for setting the environment variable PVSS_II is created. getProj.cmd starts the example and executes the temporary batch file, which is deleted afterwards.

getProj.cmd

@echo off

rem getProj.cmd

rem sets the PVSS_II variable to the current config file

call cscript //NOLOGO %~d0%~p0\getProj.vbs

call %temp%\setEnv.cmd

rm %temp%\setEnv.cmd

getProj.vbs

'getProj.vbs

'Queries the current config file and creates a command (setEnv.cmd) for 'setting the PVSS_II environment variable

option explicit

dim oProjAdmin 'as WCCOACom.ProjAdminAuto

dim sh 'as Shell

dim sProj 'as string

dim sConfig 'as string

dim fsoTmp 'as FileSystemObject

dim oTmpFile 'as File

dim i 'as integer

dim sFile 'as string

Set sh = CreateObject("WScript.Shell")

Set fsoTmp = CreateObject("Scripting.FileSystemObject")

set oProjAdmin = createObject("WCCOACom.ProjAdminAuto")

i = oProjAdmin.GetActProj(sProj)

if i <> 0 then

WScript.Echo "Error " & i & vbCrLf & "Can't get current Project!" & vbCrLf

WScript.quit

end if

i = oProjAdmin.ProjName2ConfigFile(sProj, sConfig)

if i <> 0 then

WScript.Echo "Error " & i & vbCrLf & "Can't get config file!" & vbCrLf

WScript.quit

end if

i = oProjAdmin.CheckConfigFile(sConfig, 1)

if i <> 0 then

WScript.quit

end if

sFile = sh.Environment("PROCESS")("TEMP")

set oTmpFile = fsoTmp.CreateTextFile(sFile & "\setEnv.cmd", true)

oTmpFile.WriteLine("Set PVSS_II=" & sConfig)