Windows Vista Forums

Running file iteration and other scripts under Vista security. How
  1. #1


    MarceepooNu Guest

    Running file iteration and other scripts under Vista security. How

    The script below runs just fine under Xp, but bombs out in Vista, presumably
    to do Vista's enhanced security.

    Any suggestions about how to get this script to run properly under Vista
    would be much appreciated. (I'd like to know where I can learn about how to
    deal in general with the security related problems that I'll encounter
    w/scripts under Vista. So any pointers to a good url would be much
    appreciated.)
    Thanks for your time. It is much appreciated.

    MarceepooNu

    Here's the script:
    Set objComputer = CreateObject("Shell.LocalMachine")

    sCmptrNam = objComputer.MachineName
    WScript.Echo "sCmptrNam = " & sCmptrNam

    If UCase(sCmptrNam) = "marcmacv1" Then
    strURL = "C:\Users\marxp\AppData\Roaming\Microsoft\Word\Startup"
    ElseIf UCase(sCmptrNam) = "ZAPPA" Then
    strURL = "C:\Documents and Settings\marxp.law\Application
    Data\Microsoft\Word\STARTUP"
    ElseIf Left(UCase(sCmptrNam) , 3) = "amber-2core" Then
    strURL = "C:\Documents and Settings\amber\Application
    Data\Microsoft\Word\STARTUP"
    ElseIf Left(UCase(sCmptrNam) , 4) = "RESERVED_FOR_LATER_USE" Then
    strURL = "C:\Documents and Settings\marxp\Application
    Data\Microsoft\Word\STARTUP"
    Else
    strURL = "C:\Documents and Settings\marxp\Application
    Data\Microsoft\Word\STARTUP"
    End If


    Set objShell = CreateObject("Wscript.Shell")
    objShell.Run("explorer.exe /e, " & strURL)








    --
    MarceepooNu

      My System SpecsSystem Spec

  2. #2


    Paul Randall Guest

    Re: Running file iteration and other scripts under Vista security. How


    "MarceepooNu" <mbh2010@xxxxxx> wrote in message
    news:1FCA7D5A-F386-403F-9BCF-C0B3E95EA356@xxxxxx

    > The script below runs just fine under Xp, but bombs out in Vista,
    > presumably
    > to do Vista's enhanced security.
    >
    > Any suggestions about how to get this script to run properly under Vista
    > would be much appreciated. (I'd like to know where I can learn about how
    > to
    > deal in general with the security related problems that I'll encounter
    > w/scripts under Vista. So any pointers to a good url would be much
    > appreciated.)
    > Thanks for your time. It is much appreciated.
    >
    > MarceepooNu
    >
    > Here's the script:
    > Set objComputer = CreateObject("Shell.LocalMachine")
    >
    > sCmptrNam = objComputer.MachineName
    > WScript.Echo "sCmptrNam = " & sCmptrNam
    >
    > If UCase(sCmptrNam) = "marcmacv1" Then
    > strURL = "C:\Users\marxp\AppData\Roaming\Microsoft\Word\Startup"
    > ElseIf UCase(sCmptrNam) = "ZAPPA" Then
    > strURL = "C:\Documents and Settings\marxp.law\Application
    > Data\Microsoft\Word\STARTUP"
    > ElseIf Left(UCase(sCmptrNam) , 3) = "amber-2core" Then
    > strURL = "C:\Documents and Settings\amber\Application
    > Data\Microsoft\Word\STARTUP"
    > ElseIf Left(UCase(sCmptrNam) , 4) = "RESERVED_FOR_LATER_USE" Then
    > strURL = "C:\Documents and Settings\marxp\Application
    > Data\Microsoft\Word\STARTUP"
    > Else
    > strURL = "C:\Documents and Settings\marxp\Application
    > Data\Microsoft\Word\STARTUP"
    > End If
    >
    >
    > Set objShell = CreateObject("Wscript.Shell")
    > objShell.Run("explorer.exe /e, " & strURL)
    >
    > MarceepooNu
    Hopefully someone else will actually help you with your problem. But you
    have made it rather difficult for us. "runs just fine under Xp, but bombs
    out in Vista" doesn't give us many clues as to what the problem might be.
    Why should we spend 15 minutes analyzing your script to see what the
    potential problems might be when you could so easily make the 'bomb' message
    active, hit control C, and paste the exact error info into your post. It
    would also be helpful to post the complete line on which the error occurs,
    because, due to line wrap in some newsgroup readers, what we think is line
    number x may be line number y in your script. Also it is a pain in the ...
    to count lines when you can so easily tell us the line in question.

    -Paul Randall



      My System SpecsSystem Spec

  3. #3


    MarceepooNu Guest

    RE: Running file iteration and other scripts under Vista security. How

    1. Please accept my apology.
    2. Thank you (really, no kidding) for taking the time to tell me what I did
    wrong. I will learn from this rebuke, and not make the same mistake again
    (or at least I hope I don't make the same mistake again).
    3. In case you're still willing to consider looking at my posting, the
    error message was as follows:
    Windows Script Host
    Script: K:\data\_Shtcuts\Toolbar links\B\Word.Startup-OpnDir.vbs
    Line: 15
    Char: 1
    Error: ActiveX component can't create object: 'Shell.LocalMachine'
    Code: 800A01AD
    Source: Microsoft VBScript runtime error


    The offending line 15 was this line: Set objComputer =
    CreateObject("Shell.LocalMachine")

    Once again, I am sorry for wasting your time. Your time is valuable, and
    you're giving it away freely; so there's no excuse for my wasting your time
    (except ignorance on my part, which won't be repeated for the foreseeable
    future).

    MarceepooNu






    --
    MarceepooNu


    "MarceepooNu" wrote:

    > The script below runs just fine under Xp, but bombs out in Vista, presumably
    > to do Vista's enhanced security.
    >
    > Any suggestions about how to get this script to run properly under Vista
    > would be much appreciated. (I'd like to know where I can learn about how to
    > deal in general with the security related problems that I'll encounter
    > w/scripts under Vista. So any pointers to a good url would be much
    > appreciated.)
    > Thanks for your time. It is much appreciated.
    >
    > MarceepooNu
    >
    > Here's the script:
    > Set objComputer = CreateObject("Shell.LocalMachine")
    >
    > sCmptrNam = objComputer.MachineName
    > WScript.Echo "sCmptrNam = " & sCmptrNam
    >
    > If UCase(sCmptrNam) = "marcmacv1" Then
    > strURL = "C:\Users\marxp\AppData\Roaming\Microsoft\Word\Startup"
    > ElseIf UCase(sCmptrNam) = "ZAPPA" Then
    > strURL = "C:\Documents and Settings\marxp.law\Application
    > Data\Microsoft\Word\STARTUP"
    > ElseIf Left(UCase(sCmptrNam) , 3) = "amber-2core" Then
    > strURL = "C:\Documents and Settings\amber\Application
    > Data\Microsoft\Word\STARTUP"
    > ElseIf Left(UCase(sCmptrNam) , 4) = "RESERVED_FOR_LATER_USE" Then
    > strURL = "C:\Documents and Settings\marxp\Application
    > Data\Microsoft\Word\STARTUP"
    > Else
    > strURL = "C:\Documents and Settings\marxp\Application
    > Data\Microsoft\Word\STARTUP"
    > End If
    >
    >
    > Set objShell = CreateObject("Wscript.Shell")
    > objShell.Run("explorer.exe /e, " & strURL)
    >
    >
    >
    >
    >
    >
    > --
    > MarceepooNu

      My System SpecsSystem Spec

  4. #4


    Richard Mueller [MVP] Guest

    Re: Running file iteration and other scripts under Vista security. How


    "MarceepooNu" <mbh2010@xxxxxx> wrote in message
    news:1FCA7D5A-F386-403F-9BCF-C0B3E95EA356@xxxxxx

    > The script below runs just fine under Xp, but bombs out in Vista,
    > presumably
    > to do Vista's enhanced security.
    >
    > Any suggestions about how to get this script to run properly under Vista
    > would be much appreciated. (I'd like to know where I can learn about how
    > to
    > deal in general with the security related problems that I'll encounter
    > w/scripts under Vista. So any pointers to a good url would be much
    > appreciated.)
    > Thanks for your time. It is much appreciated.
    >
    > MarceepooNu
    >
    > Here's the script:
    > Set objComputer = CreateObject("Shell.LocalMachine")
    >
    > sCmptrNam = objComputer.MachineName
    > WScript.Echo "sCmptrNam = " & sCmptrNam
    >
    > If UCase(sCmptrNam) = "marcmacv1" Then
    > strURL = "C:\Users\marxp\AppData\Roaming\Microsoft\Word\Startup"
    > ElseIf UCase(sCmptrNam) = "ZAPPA" Then
    > strURL = "C:\Documents and Settings\marxp.law\Application
    > Data\Microsoft\Word\STARTUP"
    > ElseIf Left(UCase(sCmptrNam) , 3) = "amber-2core" Then
    > strURL = "C:\Documents and Settings\amber\Application
    > Data\Microsoft\Word\STARTUP"
    > ElseIf Left(UCase(sCmptrNam) , 4) = "RESERVED_FOR_LATER_USE" Then
    > strURL = "C:\Documents and Settings\marxp\Application
    > Data\Microsoft\Word\STARTUP"
    > Else
    > strURL = "C:\Documents and Settings\marxp\Application
    > Data\Microsoft\Word\STARTUP"
    > End If
    >
    >
    > Set objShell = CreateObject("Wscript.Shell")
    > objShell.Run("explorer.exe /e, " & strURL)
    >
    Comments:

    1. I don't believe component Shell.LocalMachine exists.
    2. You can get the NetBIOS name of the local computer from the wshNetwork
    object.
    3. UCase(sCmptrNam) can never be equal to the lower case string "marcmacv1".
    4. The first 3 characters of sCmptrNam can never be equal to an 11 character
    string.
    5. The first 4 characters of sCmptrNam can never be equal to a 22 character
    string.

    I have not tested, and have not started IE from a script this way, but as a
    start I would suggest:
    ==========
    Set objNetwork = CreateObject("Wscript.Network")
    sCmptrNam = objNetwork.ComputerName
    Wscript.Echo "sCmptrNam = " & sCmptrNam

    If UCase(sCmptrNam) = "MARCMACV1" Then
    strURL = "C:\Users\marxp\AppData\Roaming\Microsoft\Word\Startup"
    ElseIf UCase(sCmptrNam) = "ZAPPA" Then
    strURL = "C:\Documents and Settings\marxp.law\Application
    Data\Microsoft\Word\STARTUP"
    ElseIf Left(UCase(sCmptrNam), 11) = "AMBER-2CORE" Then
    strURL = "C:\Documents and Settings\amber\Application
    Data\Microsoft\Word\STARTUP"
    ElseIf Left(UCase(sCmptrNam), 22) = "RESERVED_FOR_LATER_USE" Then
    strURL = "C:\Documents and Settings\marxp\Application
    Data\Microsoft\Word\STARTUP"
    Else
    strURL = "C:\Documents and Settings\marxp\Application
    Data\Microsoft\Word\STARTUP"
    End If

    Set objShell = CreateObject("Wscript.Shell")
    objShell.Run("explorer.exe /e, " & strURL)
    ========

    --
    Richard Mueller
    MVP Directory Services
    Hilltop Lab - http://www.rlmueller.net
    --



      My System SpecsSystem Spec

  5. #5


    Chip Orange Guest

    Re: Running file iteration and other scripts under Vista security. How


    "Richard Mueller [MVP]" <rlmueller-nospam@xxxxxx> wrote in
    message news:uQrOzyhaJHA.1528@xxxxxx

    >
    > "MarceepooNu" <mbh2010@xxxxxx> wrote in message
    > news:1FCA7D5A-F386-403F-9BCF-C0B3E95EA356@xxxxxx

    >> The script below runs just fine under Xp, but bombs out in Vista,
    >> presumably
    >> to do Vista's enhanced security.
    >>
    >> Any suggestions about how to get this script to run properly under Vista
    >> would be much appreciated. (I'd like to know where I can learn about how
    >> to
    >> deal in general with the security related problems that I'll encounter
    >> w/scripts under Vista. So any pointers to a good url would be much
    >> appreciated.)
    >> Thanks for your time. It is much appreciated.
    >>
    >> MarceepooNu
    >>
    >> Here's the script:
    >> Set objComputer = CreateObject("Shell.LocalMachine")
    >>
    >> sCmptrNam = objComputer.MachineName
    >> WScript.Echo "sCmptrNam = " & sCmptrNam
    >>
    >> If UCase(sCmptrNam) = "marcmacv1" Then
    >> strURL = "C:\Users\marxp\AppData\Roaming\Microsoft\Word\Startup"
    >> ElseIf UCase(sCmptrNam) = "ZAPPA" Then
    >> strURL = "C:\Documents and Settings\marxp.law\Application
    >> Data\Microsoft\Word\STARTUP"
    >> ElseIf Left(UCase(sCmptrNam) , 3) = "amber-2core" Then
    >> strURL = "C:\Documents and Settings\amber\Application
    >> Data\Microsoft\Word\STARTUP"
    >> ElseIf Left(UCase(sCmptrNam) , 4) = "RESERVED_FOR_LATER_USE" Then
    >> strURL = "C:\Documents and Settings\marxp\Application
    >> Data\Microsoft\Word\STARTUP"
    >> Else
    >> strURL = "C:\Documents and Settings\marxp\Application
    >> Data\Microsoft\Word\STARTUP"
    >> End If
    >>
    >>
    >> Set objShell = CreateObject("Wscript.Shell")
    >> objShell.Run("explorer.exe /e, " & strURL)
    >>
    >
    > Comments:
    >
    > 1. I don't believe component Shell.LocalMachine exists.
    > 2. You can get the NetBIOS name of the local computer from the wshNetwork
    > object.
    > 3. UCase(sCmptrNam) can never be equal to the lower case string
    > "marcmacv1".
    > 4. The first 3 characters of sCmptrNam can never be equal to an 11
    > character string.
    > 5. The first 4 characters of sCmptrNam can never be equal to a 22
    > character string.
    >
    > I have not tested, and have not started IE from a script this way, but as
    > a start I would suggest:
    > ==========
    > Set objNetwork = CreateObject("Wscript.Network")
    > sCmptrNam = objNetwork.ComputerName
    > Wscript.Echo "sCmptrNam = " & sCmptrNam
    >
    > If UCase(sCmptrNam) = "MARCMACV1" Then
    > strURL = "C:\Users\marxp\AppData\Roaming\Microsoft\Word\Startup"
    > ElseIf UCase(sCmptrNam) = "ZAPPA" Then
    > strURL = "C:\Documents and Settings\marxp.law\Application
    > Data\Microsoft\Word\STARTUP"
    > ElseIf Left(UCase(sCmptrNam), 11) = "AMBER-2CORE" Then
    > strURL = "C:\Documents and Settings\amber\Application
    > Data\Microsoft\Word\STARTUP"
    > ElseIf Left(UCase(sCmptrNam), 22) = "RESERVED_FOR_LATER_USE" Then
    > strURL = "C:\Documents and Settings\marxp\Application
    > Data\Microsoft\Word\STARTUP"
    > Else
    > strURL = "C:\Documents and Settings\marxp\Application
    > Data\Microsoft\Word\STARTUP"
    > End If
    >
    > Set objShell = CreateObject("Wscript.Shell")
    > objShell.Run("explorer.exe /e, " & strURL)
    > ========
    >
    > --
    > Richard Mueller
    > MVP Directory Services
    > Hilltop Lab - http://www.rlmueller.net
    > --
    >
    >

    In addition, The OP could save themselves a lot of code by replacing that
    long "If" command with a single assignment which made use of the %AppData%
    environment variable. Then no testing on computer names is even needed.


    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
    Set colItems = objWMIService.ExecQuery _
    ("Select * From Win32_Environment Where Name = 'Appdata'")
    Set objItem = colItems(1)
    strURL = objItem.VariableValue & "\microsoft\word\startup"


    hth,

    Chip




      My System SpecsSystem Spec

Running file iteration and other scripts under Vista security. How problems?

Similar Threads
Thread Thread Starter Forum Replies Last Post
running ASP scripts on Vista goluhaque Software 0 05 Sep 2009
running scripts j lunis Vista General 4 31 Jul 2008
Running scripts? Bev Vista mail 1 17 Aug 2007
Running Scripts Bev Vista mail 0 15 Aug 2007
Running scripts Marco PowerShell 3 17 Jul 2007