Refresh system variable using vbscript/QTP

谁说胖子不能爱 提交于 2019-12-13 02:58:05

问题


I want to set system variable MQSERVER for connecting to MQ using QTP. Each time this value is changed from QTP, I need to restart QTP to reflect changes.

E.g. in the system variables window, MQSERVER = ABCD

change the variable using

 Set objWSH = CreateObject("WScript.Shell")
 Set objSystemVariables = objWSH.Environment("SYSTEM") 
 objSystemVariables(MQVariableName) = MQVariableValue

The variable is set correctly but does not reflect in QTP code when connecting to websphere MQ.

Immediately when I restart QTP, the QTP reads the env variable correctly. Can you please let me know how I can use the below API method. I am getting type mismatch in QTP.

lnRetVal = SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0, "Environment", 2, 1000, Null) 'Getting type mismatch here

Updating my original question with the code that connects to queue manager.

The very basic thing that I am trying to do is (which can't be done without restarting QTP)

1) Connect to a queue manager

2) Put the message

3) Connect to another queue manager

4) Read the output

Const MQOO_OUTPUT = 16
 Const MQOO_INPUT_AS_Q_DEF = 1
 Set MQS = CreateObject("MQAX200.MQSession")                          
 Set QM = MQS.AccessQueueManager(Environment.Value("MQName")) 'This will pass the queue name and  access the queue manager.
 Set MQQueue = QM.AccessQueue(strQueName, MQOO_INPUT_AS_Q_DEF Or MQOO_OUTPUT)
 Set PutOptions = MQS.AccessPutMessageOptions()
 PutOptions.Options = MQPMO_NO_SYNCPOINT
 Set PutMsg = MQS.AccessMessage() 
 PutMsg.CharacterSet = 1208
 PutMsg.MessageData = PutMsgStr 'the message text 
 PutMsg.ApplicationIdData = "INTF_0439B" 
 MQQueue.Put PutMsg, PutOptions 'write the message to queue.

Also, my websphere MQ version is 7.0.1.8

来源:https://stackoverflow.com/questions/44627702/refresh-system-variable-using-vbscript-qtp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!