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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PUTENV Command Does not work 1

Status
Not open for further replies.

jthayer

Programmer
Oct 18, 2004
6
US
Hi,
In trying to get a return value out of Procomm 4.8, I have the following script that is supposed to set a USER (NOT SYSTEM) environment variable on Win2003 Server. Procomm is running locally and the user is running with ADMIN priviledges. Nevertheless, I cannot seem to get Procomm to set the value of the environment variable. Is my syntax ok?

Code:
proc main
	

	string EnviroString           ; String to put 

	pause 5
	
	EnviroString = "PROCOMMRV=true"   ;Set value
	
    if not putenv EnviroString                  
		errormsg "Could not set environment variable"
	else
	
		pwexit
		
	endif
	
endproc
My errormsg does NOT fire, and Procomm does exit as if Putenv had succeeded, even though it did nothing to change the environment variable's value.

By chance, is putenv only for establishing and setting NEW environment variables, as opposed to setting the values of already established variables?

Thanks

JT
 
Further info:

I tried to use the same script to create anew an environment variable (one that I had not already established). It failed. I also used Regedit to give local service permissions on HKLM\SYSTEM\CurrentControlSet\Control\Session
Manager\Environment to set and query subkey values. Still nothing. Has anyone else run into this?
JT
 
After working on this for a bit, I think that you would need to launch your VB app from a cmd window for it and Procomm to share that environment variable. After some research I did involving the set command, it looks like environment variables can only be modified in the local context of a shell or cmd window. I set a variable to FALSE in the System applet, brought up a new cmd window, checked that the value of the variable was set, used the set command to change it to TRUE, and verified that the change took in that window. However, when I went back to the System applet, the original value of FALSE was still present. So what I think is happening is that when you launch Procomm and your script modifies the environment variable, it is changing only the local "copy" and not the "master" copy seen by viewing the environment variables in the System applet in Control Panel.

Another option that may work for you is to use the profilewr command to have your script write a return code to an INI file that your program can then access. I saw this mentioned in an older thread here when searching for older threads involving putenv.

aspect@aspectscripting.com
 
Thanks knob. I think I shall try either returning a value via some other means, or transferring the file movement after successful send responsibility to the Procomm script. Thanks again.
JT
 
Hi knob. I want to thank you again for your suggestion regarding profilewr. That turned out to be the way to go. I appreciate it greatly! Would you like the source code for my sending VB.NET app? If so, let me know at westfield.eye@verizon.net.
JT
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top