Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


Running from VBScript logon script Permissions

Running from VBScript logon script Permissions

Running from VBScript logon script Permissions


I have a logon script that for historic reasons is written in VBScript. However, due to Citrix Xen 6, I have had to use powershell to obtain the thin client name using Xen 6 APIs. The powershell script is 'embedded' into the VBScript. No .PS1 file.

The code executes successfully for an administrator, but doesn't return the thin client name when executed as an ordinary user. If I was running the .PS1 file, I would expect the Set-ExecutionPolicy command to solve the issue. All though we have tried setting executionPolicy to both RemoteSigned and Unristricted we haven't had any luck.

So the question is, does anyone know if there is a way and if so could they point me in the right direction, or do we have to call the .ps1 script?

Here is the VBScript code:


Function getTerminalName()
Set oShell = CreateObject("WScript.Shell")

strDomain = oShell.ExpandEnvironmentStrings("%USERDOMAIN%")
strUsername = oShell.ExpandEnvironmentStrings("%USERNAME%")
strAccount = strDomain &"\"& strUsername

pscommand = "Add-PSSnapin citrix* ; $sessions = Get-XASession -Account " & strAccount & " | ? {$_.ServerName -eq (gc env:computername)} ; foreach ($Item in $sessions) { write-host $Item.ClientName } ; exit $sessions "
cmd = "powershell.exe -noprofile -windowstyle Hidden -command " & pscommand
Set tcName = oShell.Exec(cmd)

tcName = Left(tcName.StdOut.ReadAll,3)
getTerminalName = tcName
End Function

If anyone could shed any light on how one might execute this code as an ordinary user, I'd be most grateful for any assistance.

Many thanks


RE: Running from VBScript logon script Permissions

From your description, it doesn't sound like an Execution Policy issue. That only controls whether scripts can run or not. Execution Policy does not affect running commands directly, such as your embedded command.

It seems more like a permissions issue with non-Administrator accounts. Maybe they can't add the Citrix snap-in, or if they can then maybe they can't read the thin client name information.

Can you set up a test non-Administrator account that could access Powershell interactively? Then you could run those PS commands and maybe see where the failure occurs. I don't know anything about Xen 6 so can't offer any help beyond that.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close