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

Envirnment settings. 1

Status
Not open for further replies.

sparkbyte

Technical User
Sep 20, 2002
879
US
Hey guys, Long time since I have needed your expertise.

I have a script that automats the installation and launching of a software client. Base on groups membership the script will either run a "browser" version or a "Win100" (old DOS style).

There seems to be a difference on how windows treats environment variables.

This works.
Code:
Sub Win100_Working()
			' Run CORE Win100 Client
			' Set path to Win100 executable
			sExePath = "E:\Program Files\CoreDir\Core_Main\Config\BK" &_
			strBank & "\corelogin.bat"
			sSwitches = ""

			If objFSO.FileExists(sExePath) Then
				objShell.Run Chr(34) & sExePath & Chr(34) & " " & sSwitches, 3, False 
			Else 
			End If 
End Sub
the bat file this runs is this.
Code:
[highlight]SET SFWINIPATH=E:\PROGRA~1\CoreDir\Users\113$FR~1\BK113[/highlight]
IF EXIST "E:\Program Files\CoreDir\Core_Main\Config\BK113\OSGWSUPD.EXE" START /W "OSGWSUPD" /MIN "E:\Program Files\CoreDir\Core_Main\Config\BK113\OSGWSUPD.EXE"
IF NOT ERRORLEVEL 1 START E:\PROGRA~1\CoreDir\CORE_M~1\SYNERG~1\\dbl\bin\dbr.exe BIN:MNUMNU

This does not.
Code:
Sub Win100_Not Working()
[highlight]
			Set WshSystemEnv = objShell.Environment("USER")
			WshSystemEnv(SFWINIPATH) = "E:\PROGRA~1\CoreDir\Users\" & strUser &_
			"\BK" & strBank
[/highlight]
			' Run CORE Win100 Client
			' Set path to Win100 executable
			sExePath = "E:\PROGRA~1\CoreDir\CORE_M~1\SYNERG~1\dbl\bin\dbr.exe"
			sSwitches = "BIN:MNUMNU"

			If objFSO.FileExists(sExePath) Then
				objShell.Run Chr(34) & sExePath & Chr(34) & " " & sSwitches, 3, False 
			Else 
			End If 
End Sub


Could someone tell me if there is supposed to be a difference in how these are running other than the fact that one is launched via BAT file and the other soley in VBS?

Thanks
John Fuhrman


Thanks

John Fuhrman
Titan Global Services
 
I've never used Wsh.Environment like that.

The question that springs to mind is whether you have got the right group? There are two groups: SYSTEM and USER. Is SFWINIPATH defined in the correct one.

Is SFWINIPATH already defined and you're overriding it or has it not been defined and you're setting it before running the code.
 
>[tt]SET SFWINIPATH=E:\PROGRA~1\CoreDir\Users\113$FR~1\BK113[/tt]

If the above is the working version, then this won't work.

>WshSystemEnv(SFWINIPATH) = "E:\PROGRA~1\CoreDir\Users\" & strUser &_
> "\BK" & strBank

SFWINIPATH is a string name of the env variable.

[tt]WshSystemEnv([highlight]"[/highlight]SFWINIPATH[highlight]"[/highlight]) = "E:\PROGRA~1\CoreDir\Users\" & strUser &_
"\BK" & strBank[/tt]

Also the few lines alone are already floaded with global variables - not a good practice at all.
 
thanks tsuji, it figures my mistake would be with syntax. I will try out the change Monday.



Thanks

John Fuhrman
Titan Global Services
 
I do them this way

Code:
Dim WshShell:    Set WshShell = CreateObject("Wscript.Shell")

'Write to Users env variables
WshShell.Environment("USER").Item("TMP") = "C:\%systemroot%\TMP"
WshShell.Environment("USER").Item("TEMP") = "C:\%systemroot%\TEMP" 

'Write to System  env variables
WshShell.Environment("SYSTEM").Item("YourName3") = "world"
 
Grim a star for you. That fixed the environment problem. But what seems to be still giving me fits is the workign directory. Is there a way to set the start up directory from a Run?

Thanks

John Fuhrman
Titan Global Services
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top