Skip navigation
2394 Views 2 Replies Latest reply: Apr 5, 2011 8:41 AM by DanDinolfo RSS
rayjen0919 Apprentice 137 posts since
Sep 30, 2009

Has received 1 of 9 achievements.
Currently Being Moderated

Apr 4, 2011 4:09 AM

VBS via LANDesk

Dear All,

 

I've created a batch for copying a folder that carry one execution file and a vbs file.

the vbs file is used to make shortcut of the execution file to target user desktop.

When I try the batch locally on a machine, it works fine!

However, I try to deploy it via LANDesk and strange result came out.

The shortcut can't located in user desktop but located in root drive C:

I've no idea what it is happening... ???

Any advise? thanks!

Ray

 

p.s. the vbs is attachd for your reference.

Attachments:
  • chad SupportEmployee 109 posts since
    Nov 15, 2007

    Has received 5 of 9 achievements.
    Currently Being Moderated
    1. Apr 4, 2011 7:56 AM (in response to rayjen0919)
    Re: VBS via LANDesk

    By default we use LocalSystem to run packages which can cause issues when copying to user profiles.

     

    In the properties of the package change the Account to use to the logged on user, and try it again.  Alternatively, you can use the All Users folder with LocalSystem and that should work as well.

  • Apprentice 160 posts since
    Mar 18, 2010

    Has received 1 of 9 achievements.
    Currently Being Moderated
    2. Apr 5, 2011 8:41 AM (in response to chad)
    Re: VBS via LANDesk

    I made a function that will restart your vbscript as the logged in user.  It's pretty slick. Just call it at the start of the script and it should always run as the logged in user.  I typically wouldn't do that, as if I wanted the entire script to run as the logged in user, I would just do as described and change the package to do that.  What I use this for is more when I have some parts that I want to run as system.  For instance, if you had a script that needed to write to the HKLM and HKCU hives, your script would fail if you ran the entire thing as the user, (if the user wasn't an Administrator).  So I would run the script as the system account but do a couple tasks as the logged in user.  So instead of having the function call the script, I might have it call the script and pass some command line variables that tell the script that it's already done part of the work.  Then I check for that and skip ahead 20 lines or so.  I hope that makes sense.

     

    'Force the script to run as the local user.  Useful for LANDesk.
    Function ForceLocalUser

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

    eUserProfile = oShell.ExpandEnvironmentStrings("%UserProfile%")

    eProgramFiles = oShell.ExpandEnvironmentStrings("%ProgramFiles%")

    eWinDir = oShell.ExpandEnvironmentStrings("%WinDir%")
        If right(eUserProfile,12) = "LocalService" Or Right(eUserProfile, 13) = "systemprofile" Then
            oShell.Run """" & eProgramFiles & "\LANDesk\LDClient\startasuser.exe"" " & eWinDir & "\System32\wscript.exe " & """" & WScript.ScriptFullName & """",0,True
            ForceLocalUser = True
            WScript.Quit
        Else
            ForceLocalUser = False
        End If   
    End Function

More Like This

  • Retrieving data ...

Bookmarked By (0)

Legend

  • Correct Answers - 20 points
  • Helpful Answers - 10 points
LANDESK Community powered by Jive SBS® 4.5.7.1  |  Legal Notices  |  Privacy Policy  |  Icon 

TweeterOn Twitter  |  Icon FacebookOn Facebook © 2007 LANDESK Software