Link to home
Start Free TrialLog in
Avatar of Preben Josefsen
Preben JosefsenFlag for Denmark

asked on

find logon server in a vbs logon script

I need to know which logon server the user is logging on to in a vbs script that I run. In cmd I used %logonserver% but how do I do this in vbs ?
ASKER CERTIFIED SOLUTION
Avatar of Brian Mulder
Brian Mulder
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of AmigoJack
AmigoJack

you can call the commandline

ShellExecute(0, vbNull, "cmd /c echo %logonserver% >logonserver.txt", vbNull, vbNull, 0)

and then read out "logonserver.txt".
Hi maxmull,

dim wshshell
Dim wshenv
set wshshell = CreateObject("Wscript.Shell")
set wshenv = WshShell.Environment("VOLATILE")
msgbox wshenv("LOGONSERVER")

Will do this.

Tim Cottee
Avatar of Preben Josefsen

ASKER

LogonServer  = WshShell.ExpandEnvironmentStrings("%LOGONSERVER%")

This seems to work for me.