WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Environment

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Call Function and Environment Path

Keywords: call function environment path 

Question:

I'm new to Winbatch so this may be a dumb question but I'm at the end of my rope. The CALL function appears to be using the Command prompt (CMD.EXE) path variable to locate the called item (in this case an encoded Winbatch script - .WBC). Is there any way to make the CALL function use the Windows NT system and user path variables to locate the called item? I have extracted these variables from the registry and tried to use the ENVIRONSET function prior to the CALL, but this didn't work. I would appreciate any new ideas.

Answer (Part #1):

Hmmm.
  1. Use EnvItemize to check what the environment looks like to Winbatch.
  2. You could locate the file yourself and call it directly.

Method 1

	wbc=FileLocate("xxx.wbc") 
	Call(wbc,"") 

Method 2

	a=Environment("SystemDir") 
	b=strlen(a) 
	if strsub(a,b,1)!="\") then a=strcat(a,"\") 
	wbc=strcat(a,"xxx.wbc") 
	Call(wbc,"") 

Continued:

After further review, I have discovered that my problem centers around the length of the new path passed to EnvironSet. If the new path is greater than 256 characters, the function clears the existing DOS Path variable. Is there any workaround for this?

Example:

	a=Environment("path") 
	message ("Original DOS Path", a)

	c = "New Path (if this is greater than 256 characters, EnvironSet does not work)"
	EnvironSet("PATH", c)

	a=Environment("path") 
	message ("DOS Path After Environset", a)
 

Answer (Part #2):

The DOS Path variable used to be limited to 126 characters, and someplace along the line it was doubled to 255. This is an operating system limitation. WinBatch does not truncate any environment variable. It seems the system is doing it, and is out of our control. The WinBatch Environment function works up to 255 characters and then it will keel over and die.

In addition, sometimes Windows 95 & NT pre-pends the directory information for the bat file onto the front of the path, making the path larger still. You may need to find other means to modify the path.

You can write to the registry to modify environment variables, bypassing the Windows method of doing it.

If you are using Windows 95 or NT 4.0, check out the RegApp function that can set the path for a particular EXE file.


Article ID:   W12912
Filename:   Call Function and Environment Path.txt
File Created: 1999:04:15:16:50:28
Last Updated: 1999:04:15:16:50:28