Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
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.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Will not work in Vista

Reply
 
Old 02-05-2009   #1 (permalink)
La


 
 

Will not work in Vista

Can someone identify and provide guideance to why the following script will
not run?
It runs great on XP

On Error Resume Next

Const HKEY_LOCAL_MACHINE = &H80000002
dim vbYesNo
dim vbQuestion
vbYesNo = 4
vbQuestion = 48

'Create inputbox in order to collect the computer Name
'----------------------------

StrComputer=InputBox("Enter Name of the Remote Computer...","Connect to
Remote Computer")

'Connect to the Remote Registry using WMI space
'I assume that you have administrative rights ?
'---------------------------------

Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
strComputer & "\root\default:StdRegProv")

'Error handling...if not able to connect to the remote machine...you will
be notified
'---------------------------------------------------------

If Err.Number <> 0 Then
MsgBox "Error. Computer not accessible...Possible reasons" & vbcrlf &
vbcrlf &_
"1. The computer name is incorrect" & vbcrlf & _
"2. Your too stupid to use the script" & vbcrlf & _
"3. The computer is not running... " & vbcrlf & _
"4. The currently logged-on user has no admin rights"& vbcrlf &
vbcrlf &_
"End of Script",64,"An Error occured"
WScript.Quit()
End If

'to disable CAC Login requirement,
'registry key
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\scforceoption
'should be set to 0

strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System"
strValueName = "scforceoption"
dwValue = 0
oReg.SetDWORDValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,dwValue

WScript.echo " Action completed sucessfully "




My System SpecsSystem Spec
Old 02-05-2009   #2 (permalink)
Al Dunbar


 
 

Re: Will not work in Vista


"La" <La@xxxxxx> wrote in message
news:A7B6BFC3-3A54-4F3A-89A2-13BCF05CF4AC@xxxxxx
Quote:

> Can someone identify and provide guideance to why the following script
> will
> not run?
> It runs great on XP
>
> On Error Resume Next
>
> Const HKEY_LOCAL_MACHINE = &H80000002
> dim vbYesNo
> dim vbQuestion
> vbYesNo = 4
> vbQuestion = 48
>
> 'Create inputbox in order to collect the computer Name
> '----------------------------
>
> StrComputer=InputBox("Enter Name of the Remote Computer...","Connect to
> Remote Computer")
>
> 'Connect to the Remote Registry using WMI space
> 'I assume that you have administrative rights ?
> '---------------------------------
>
> Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
> strComputer & "\root\default:StdRegProv")
>
> 'Error handling...if not able to connect to the remote machine...you
> will
> be notified
> '---------------------------------------------------------
>
> If Err.Number <> 0 Then
> MsgBox "Error. Computer not accessible...Possible reasons" & vbcrlf &
> vbcrlf &_
> "1. The computer name is incorrect" & vbcrlf & _
> "2. Your too stupid to use the script" & vbcrlf & _
> "3. The computer is not running... " & vbcrlf & _
> "4. The currently logged-on user has no admin rights"& vbcrlf &
> vbcrlf &_
> "End of Script",64,"An Error occured"
> WScript.Quit()
> End If
>
> 'to disable CAC Login requirement,
> 'registry key
> HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\scforceoption
> 'should be set to 0
>
> strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System"
> strValueName = "scforceoption"
> dwValue = 0
> oReg.SetDWORDValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,dwValue
>
> WScript.echo " Action completed sucessfully "
Perhaps if you would indicate what happens when you attempt to run it, that
would make it easier for us to narrow things down for you...

/Al


My System SpecsSystem Spec
Old 02-05-2009   #3 (permalink)
Richard Mueller [MVP]


 
 

Re: Will not work in Vista


"La" <La@xxxxxx> wrote in message
news:A7B6BFC3-3A54-4F3A-89A2-13BCF05CF4AC@xxxxxx
Quote:

> Can someone identify and provide guideance to why the following script
> will
> not run?
> It runs great on XP
>
> On Error Resume Next
>
> Const HKEY_LOCAL_MACHINE = &H80000002
> dim vbYesNo
> dim vbQuestion
> vbYesNo = 4
> vbQuestion = 48
>
> 'Create inputbox in order to collect the computer Name
> '----------------------------
>
> StrComputer=InputBox("Enter Name of the Remote Computer...","Connect to
> Remote Computer")
>
> 'Connect to the Remote Registry using WMI space
> 'I assume that you have administrative rights ?
> '---------------------------------
>
> Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
> strComputer & "\root\default:StdRegProv")
>
> 'Error handling...if not able to connect to the remote machine...you
> will
> be notified
> '---------------------------------------------------------
>
> If Err.Number <> 0 Then
> MsgBox "Error. Computer not accessible...Possible reasons" & vbcrlf &
> vbcrlf &_
> "1. The computer name is incorrect" & vbcrlf & _
> "2. Your too stupid to use the script" & vbcrlf & _
> "3. The computer is not running... " & vbcrlf & _
> "4. The currently logged-on user has no admin rights"& vbcrlf &
> vbcrlf &_
> "End of Script",64,"An Error occured"
> WScript.Quit()
> End If
>
> 'to disable CAC Login requirement,
> 'registry key
> HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\scforceoption
> 'should be set to 0
>
> strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System"
> strValueName = "scforceoption"
> dwValue = 0
> oReg.SetDWORDValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,dwValue
>
> WScript.echo " Action completed sucessfully "
>
First off, it should help to specify authentication level. Use:

Set oReg = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate,authenticationLevel=Pkt}!\\" _
& strComputer & "\root\default:StdRegProv")

Otherwise, we need to know the error message and the statement that raised
the error. For that, only use "On Error Resume Next" for the one statement
where you trap errors. For example, remove your "On Error Resume Next"
statement, then you could use:
=========
On Error Resume Next
Set oReg = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate,authenticationLevel=Pkt}!\\" _
& strComputer & "\root\default:StdRegProv")
If Err.Number <> 0 Then
' Restore normal error handling.
On Error GoTo 0
MsgBox "Error. Computer not accessible...Possible reasons" & vbcrlf &
vbcrlf & _
"1. The computer name is incorrect" & vbcrlf & _
"2. Your too stupid to use the script" & vbcrlf & _
"3. The computer is not running... " & vbcrlf & _
"4. The currently logged-on user has no admin rights" & vbcrlf &
vbcrlf & _
"End of Script", 64, "An Error occured"
WScript.Quit()
End If

' Restore normal error handling.
On Error GoTo 0
===========

Actually, when I copied your MsgBox statement I thought it had errors (which
I corrected). That's why I restored normal error handling even before the
MsgBox statement, and you don't use the Err object anyway. Better still
would be the following, which would display the exact error, not a guess:
==========
On Error Resume Next
Set oReg = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate,authenticationLevel=Pkt}!\\" _
& strComputer & "\root\default:StdRegProv")
If (Err.Number <> 0) Then
Call MsgBox("Error number: " & Err.Number _
& vbCrLf & "Description: " & Err.Description _
& vbCrLf & "Source: " & Err.Source, _
vbCritical + vbOKOnly, "Error connecting")
Wscript.Quit
End If

' Restore normal error handling.
On Error GoTo 0
===========
Note that I don't restore normal error handling just before the MsgBox
statement now because I use the Err object, which would be cleared by the
"On Error GoTo 0" statement. Now if an error occurs elsewhere you will get
an error message.

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


My System SpecsSystem Spec
Old 02-06-2009   #4 (permalink)
La


 
 

Re: Will not work in Vista

Works like a charm - I received an error due to my not having permissions
(received an error 70), but other users with permission are able to
successfully use it now.

Danke

"Richard Mueller [MVP]" wrote:
Quote:

>
> "La" <La@xxxxxx> wrote in message
> news:A7B6BFC3-3A54-4F3A-89A2-13BCF05CF4AC@xxxxxx
Quote:

> > Can someone identify and provide guideance to why the following script
> > will
> > not run?
> > It runs great on XP
> >
> > On Error Resume Next
> >
> > Const HKEY_LOCAL_MACHINE = &H80000002
> > dim vbYesNo
> > dim vbQuestion
> > vbYesNo = 4
> > vbQuestion = 48
> >
> > 'Create inputbox in order to collect the computer Name
> > '----------------------------
> >
> > StrComputer=InputBox("Enter Name of the Remote Computer...","Connect to
> > Remote Computer")
> >
> > 'Connect to the Remote Registry using WMI space
> > 'I assume that you have administrative rights ?
> > '---------------------------------
> >
> > Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
> > strComputer & "\root\default:StdRegProv")
> >
> > 'Error handling...if not able to connect to the remote machine...you
> > will
> > be notified
> > '---------------------------------------------------------
> >
> > If Err.Number <> 0 Then
> > MsgBox "Error. Computer not accessible...Possible reasons" & vbcrlf &
> > vbcrlf &_
> > "1. The computer name is incorrect" & vbcrlf & _
> > "2. Your too stupid to use the script" & vbcrlf & _
> > "3. The computer is not running... " & vbcrlf & _
> > "4. The currently logged-on user has no admin rights"& vbcrlf &
> > vbcrlf &_
> > "End of Script",64,"An Error occured"
> > WScript.Quit()
> > End If
> >
> > 'to disable CAC Login requirement,
> > 'registry key
> > HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\scforceoption
> > 'should be set to 0
> >
> > strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System"
> > strValueName = "scforceoption"
> > dwValue = 0
> > oReg.SetDWORDValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,dwValue
> >
> > WScript.echo " Action completed sucessfully "
> >
>
> First off, it should help to specify authentication level. Use:
>
> Set oReg = GetObject("winmgmts:" _
> & "{impersonationLevel=impersonate,authenticationLevel=Pkt}!\\" _
> & strComputer & "\root\default:StdRegProv")
>
> Otherwise, we need to know the error message and the statement that raised
> the error. For that, only use "On Error Resume Next" for the one statement
> where you trap errors. For example, remove your "On Error Resume Next"
> statement, then you could use:
> =========
> On Error Resume Next
> Set oReg = GetObject("winmgmts:" _
> & "{impersonationLevel=impersonate,authenticationLevel=Pkt}!\\" _
> & strComputer & "\root\default:StdRegProv")
> If Err.Number <> 0 Then
> ' Restore normal error handling.
> On Error GoTo 0
> MsgBox "Error. Computer not accessible...Possible reasons" & vbcrlf &
> vbcrlf & _
> "1. The computer name is incorrect" & vbcrlf & _
> "2. Your too stupid to use the script" & vbcrlf & _
> "3. The computer is not running... " & vbcrlf & _
> "4. The currently logged-on user has no admin rights" & vbcrlf &
> vbcrlf & _
> "End of Script", 64, "An Error occured"
> WScript.Quit()
> End If
>
> ' Restore normal error handling.
> On Error GoTo 0
> ===========
>
> Actually, when I copied your MsgBox statement I thought it had errors (which
> I corrected). That's why I restored normal error handling even before the
> MsgBox statement, and you don't use the Err object anyway. Better still
> would be the following, which would display the exact error, not a guess:
> ==========
> On Error Resume Next
> Set oReg = GetObject("winmgmts:" _
> & "{impersonationLevel=impersonate,authenticationLevel=Pkt}!\\" _
> & strComputer & "\root\default:StdRegProv")
> If (Err.Number <> 0) Then
> Call MsgBox("Error number: " & Err.Number _
> & vbCrLf & "Description: " & Err.Description _
> & vbCrLf & "Source: " & Err.Source, _
> vbCritical + vbOKOnly, "Error connecting")
> Wscript.Quit
> End If
>
> ' Restore normal error handling.
> On Error GoTo 0
> ===========
> Note that I don't restore normal error handling just before the MsgBox
> statement now because I use the Err object, which would be cleared by the
> "On Error GoTo 0" statement. Now if an error occurs elsewhere you will get
> an error message.
>
> --
> Richard Mueller
> MVP Directory Services
> Hilltop Lab - http://www.rlmueller.net
> --
>
>
>
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
speakers randomly wont work sometimes on laptop but external will sometime work Sound & Audio
Still searching for way to get Vista search to work: Why doesn't FilterFilesWithUnknownExtensions registry key work in Vista? Vista General
all cd's don't work, but dvd's still work Vista hardware & devices
HP LaserJet 1010 don't work in Vista since Beta2 - Advanced 1384 Printing Support drivers for XP don't work Vista print fax & scan
Will all the programs that work on xp work on vista? Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46