Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old December 5th, 2003, 10:55 AM
RTC RTC is offline
Registered User
Join Date: Dec 2003
Location: , , .
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...

Reply With Quote
  #2 (permalink)  
Old December 5th, 2003, 01:24 PM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 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.
Reply With Quote
  #3 (permalink)  
Old June 8th, 2005, 04:03 AM
Registered User
Join Date: Jun 2005
Location: jaipur, rajasthan, India.
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....

Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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

All times are GMT -4. The time now is 04:43 AM.

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