Hi Guys,
I see a variation in output between C and python code in Windows trying to get the same functionality. The c code ( similar to unix shell scripts ) shows the TEST1 environment variable in 'test.bat.output' with its value as empty string whereas the python code removes this environment variable.
Is there a way to ask Python not to remove the environment variable from environ table when it is empty?
C
#include <windows.h>
main()
{
DWORD dwRet;
char pszOldVal[1024] = "abc";
if(! SetEnvironmentVariable("TEST1", ""))
puts("Error\n");
// _putenv("TEST1=");
// GetEnvironmentVariable("TEST1", pszOldVal, dwRet);
system("cmd /c test.bat >test.bat.output");
}
Python
import os
os.environ['TEST1'] = ""
os.environ['TEST2'] = "karthik"
os.system("cmd /c test.bat > test.bat.output.python")
-Karthik