Wrox Programmer Forums
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old December 5th, 2003, 10:55 AM
RTC RTC is offline
Registered User
Join Date: Dec 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default WScript

can anybody help with some WScript as I am completely new to this.
I am working in an intranet environment and basically need to do the following:
1: Access the computer name of a user, who is calling an asp page
2: Get the active printer of that user and change it's settings
3: Print out an asp page with the new printer settings

can this be done?
I have played around a bit with WScript, but can't seem to get the computer name of the user (or it always returns the server name, where the asp script is run at) and when I try to run the following code I get the error message "Error Type:(0x80041003)", it errors on GetObject(), which I think means I don't have permission to do the following:

function TranslateDomainRole(byVal roleID)
    Dim a

    Select Case roleID
        Case 0
            a = "Standalone Workstation"
        Case 1
            a = "Member Workstation"
        Case 2
            a = "Standalone Server"
        Case 3
            a = "Member Server"
        Case 4
            a = "Backup Domain Controller"
        Case 5
            a = "Primary Domain Controller"
    End Select
    TranslateDomainRole = a
end function

Dim s, System, item
Set System = GetObject("winmgmts:").instancesOf("Win32_Computer System")
for each item in system'
    s = "Computer Info" & vbcrlf
    s = s & "***********************" & vbcrlf
    s = s & "Name: " & item.name & vbcrlf
    s = s & "Status: " & item.status & vbcrlf
    s = s & "Type: " & item.SystemType & vbcrlf
    s = s & "Mfg: " & item.Manufacturer & vbcrlf
    s = s & "Model: " & item.Model & vbcrlf
    s = s & "RAM: ~" & item.TotalPhysicalMemory\1024000 & "mb" & vbcrlf
    s = s & "Domain: " & item.Domain & vbcrlf
    s = s & "Role: " & TranslateDomainRole(item.DomainRole) & vbcrlf
    s = s & "Current User: " & item.UserName & vbcrlf
    wscript.echo s

any help is greatly appreciated...

Old December 5th, 2003, 01:24 PM
Imar's Avatar
Wrox Author
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts

Hi there,

How are you running this code? Between <% and %> or between client side VBScript tags (<script>)?

If you're using <% the code will run on the server, so the server name is returned.

Make sure you run the code at the client if you want to retrieve the client's name. Also, make sure you have sufficient permissions (the website needs permissions) to run the script at the client. You probably need to add the server to the Trusted Sites of IE.



Imar Spaanjaars
Everyone is unique, except for me.
Old June 8th, 2005, 04:03 AM
Registered User
Join Date: Jun 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts

Following is the source of ASP
strComputer = "."
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonat e}!\\" & strComputer & "\root\cimv2")
set objRefresher = CreateObject("WbemScripting.SWbemRefresher")
Set objMemory = objRefresher.AddEnum (objWMIService, "Win32_PerfFormattedData_PerfOS_Memory").objec tSet

    For Each intAvailableBytes in objMemory
        If intAvailableBytes.AvailableMBytes < 4 Then
            Wscript.Echo "Available memory has fallen below 4 megabytes."
        End If

...and following is the error thrown by the browser
Technical Information (for support personnel)

Error Type:
/aa/lisTrusted.asp, line 17

Browser Type:
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.1.4322)

GET /aa/lisTrusted.asp

Wednesday, June 08, 2005, 11:31:00 AM
...what could be the reason
please help....

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with WScript.Shell object ninja_kornjaca Classic ASP Components 6 June 9th, 2008 01:35 AM
Please help me in WScript.Shell scripting shahhussain Classic ASP Professional 3 October 3rd, 2006 03:11 PM
Error in WScript.CreateObject pankaj.talk Pro VB.NET 2002/2003 1 June 5th, 2006 03:34 PM
Wscript.echo - How to change font size?? warewulf Beginning VB 6 0 December 27th, 2005 07:20 PM
Wscript Permissions Problem orph351 Classic ASP Components 0 September 4th, 2003 03:25 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.