Page 1 of 1

VBScript Error : 0, 0000h

Posted: Wed May 30, 2012 8:54 pm
by bigsheddy5
Hi, I have a script I am trying to use in querying the registry of remote computers to copy the LocaleName to a network share. I am testing the script but gets an error: 0, 0000h. Been trying to no avail to debug the error. please someone help; plus I am newbie to vbscripting. the script is shown below:

Option Explicit
Dim objFSO, objFolder, objShell, objTextFile, objFile
Dim strDirectory, strFile, strText, WshShell, objNetwork
strDirectory = "Win2008r2NetworkshareQuery"
strFile = "Locale.txt"
strText = " "

On Error Resume Next

'The Bit that Queries the Registry for User Locale Settings
Set WshShell = WScript.CreateObject("WScript.Shell")
Set objNetwork = wscript.CreateObject("")
WshShell.Run "cmd /c reg query " & Chr(34) & "hkcucontrol panelinternational" & Chr(34) & " /v "_
& Chr(34) & "LocaleName" & Chr(34) & " > " & "Win2008r2NetworkshareLocaleQuery" & objNetwork.Username & ".txt"

' Catch Error here...
if err.number = 0 Then
set strText = strText & "Script completed successfully"
WScript.Echo "Script completed successfully"
else if Err.Number <> 0 then
' An exception occurred
Set strText = strText & "Exception:" & " Error number: " & Err.Number & " Error description: " & Err.Description
WScript.echo strText
End If

' Create the File System Object
Set objFSO = CreateObject("Scripting.FileSystemObject")

' Check that the strDirectory folder exists
If objFSO.FolderExists(strDirectory) Then
Set objFolder = objFSO.GetFolder(strDirectory)
Set objFolder = objFSO.CreateFolder(strDirectory)
WScript.Echo "Just created " & strDirectory
End If

If objFSO.FileExists(strDirectory & strFile) Then
Set objFolder = objFSO.GetFolder(strDirectory)
Set objFile = objFSO.CreateTextFile(strDirectory & strFile)
Wscript.Echo "Just created " & strDirectory & strFile
End If

set objFile = nothing
set objFolder = Nothing
' OpenTextFile Method needs a Const value
' ForAppending = 8 ForReading = 1, ForWriting = 2
Const ForAppending = 8

Set objTextFile = objFSO.OpenTextFile(strDirectory & strFile, ForAppending, True)

' Appends strText which holds the error values every time you run this VBScript


' Bonus or cosmetic section to launch explorer to check file
If err.number = vbEmpty then
Set objShell = CreateObject("WScript.Shell") ("Explorer" &" " & strDirectory & "" ) ("Explorer.exe" &" " & "Win2008r2Networkshare" & objNetwork.Username & ".txt" )
Else WScript.echo " Textfile Append Unsuccessful.."
End If

End If

VBScript Error : 0, 0000h

Posted: Wed May 30, 2012 9:15 pm
by jvierra
Your code does not make a lot of sense. Start by describing what it is you are trying to do.

It is impossibel to get an error 0 in vbscript. The error is coming from something else like the reg command because you are giving it a bad commandline.

Code: Select all

cmd = "cmd /c reg query ""hkcucontrol panelinternational"" /v LocaleName > Win2008r2NetworkshareLocaleQuery" & objNetwork.Username & ".txt"
WshShell.Run cmd

VBScript Error : 0, 0000h

Posted: Wed May 30, 2012 9:32 pm
by jvierra
Try it like this:

Code: Select all

Const strRootFolder = "Win2008r2NetworkshareLocaleQuery"
Set oNet = wscript.CreateObject("WScript.Network") 
sFileName= strRootFolder & oNet.Username & ".txt"
' get local from registry - no error because this would mean Windows is corrupt and it would not be running
Set shell = CreateObject("WScript.Shell")
locale = shell.RegRead("HKCUcontrol panelinternationallocale")
WScript.Echo  "[ & Now & ] User:" & oNet.Username & " Locale:" & locale
'write to file
Set fso = CreateObject("Scripting.FileSystemObject")
On Error Resume Next  ' possibel error on open or create
Set file = fso.OpenTextFile(sFileName,8,True)
If Err Then
    WScript.Echo Err.Description
    WScript.Quit -1
    On Error GoTo 0  ' always turn errors back on
    file.Write locale
End If

# - fixed typosjvierra2012-05-31 04:39:44

VBScript Error : 0, 0000h

Posted: Wed May 30, 2012 9:40 pm
by jvierra
I just fixed the code I posted above. I had some typos that needed help.

VBScript Error : 0, 0000h

Posted: Wed May 30, 2012 9:46 pm
by bigsheddy5
ok, i got you.

I need to know the various locale settings for various users in different locations to enable us understand the different OS locale settings acrossdifferent branch office location for subsequent OS upgrade configuration.

So i intend to run the script remotely but first need to make sure it works correctly.


VBScript Error : 0, 0000h

Posted: Wed May 30, 2012 10:03 pm
by jvierra
Here is another morsel that may be easier to understand.

Code: Select all

gwmi win32_operatingsystem -computer pc002 ,pc003, pc004 |
     select csname, registereduser,locale, oslanguage|ft -auto

VBScript Error : 0, 0000h

Posted: Fri Jun 22, 2012 3:27 am
by jvierra
Why would you use teh registry from a batch file when WMI is all set uyp to do this remotely and is much easier to script.

PowerSHell also has all of the primitives for converting and reporting on locale.

You answer also has nothing to do with teh question. It is a batch file to get values of McAfee ePO. The question isj about determining the locale of a machine.

The whole point of the discussion is to note that using REF is an unreliable methood.. Theregie=try locations for these thngs can change from OS to OS. Using WMI is far more reliable.

ALso the issue of reading the specific users locale is not addressed.

An example of using a remote registry script from VBScritp and using REG to the requested key were also given so it is not clear why you would post a reference to the McAfee key.