![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | 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 Specs![]() |
| | #2 (permalink) |
| | Re: Running file iteration and other scripts under Vista security. How "MarceepooNu" <mbh2010@xxxxxx> wrote in message news:1FCA7D5A-F386-403F-9BCF-C0B3E95EA356@xxxxxx Quote: > 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 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 Specs![]() |
| | #3 (permalink) |
| | 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: Quote: > 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 Specs![]() |
| | #4 (permalink) |
| | Re: Running file iteration and other scripts under Vista security. How "MarceepooNu" <mbh2010@xxxxxx> wrote in message news:1FCA7D5A-F386-403F-9BCF-C0B3E95EA356@xxxxxx Quote: > 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) > 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 Specs![]() |
| | #5 (permalink) |
| | Re: Running file iteration and other scripts under Vista security. How "Richard Mueller [MVP]" <rlmueller-nospam@xxxxxx> wrote in message news:uQrOzyhaJHA.1528@xxxxxx Quote: > > "MarceepooNu" <mbh2010@xxxxxx> wrote in message > news:1FCA7D5A-F386-403F-9BCF-C0B3E95EA356@xxxxxx Quote: >> 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 Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| running ASP scripts on Vista | Software | |||
| running scripts | Vista General | |||
| Running scripts? | Vista mail | |||
| Running Scripts | Vista mail | |||
| Running scripts | PowerShell | |||