Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6216937
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T07:20:15+00:00 2026-05-24T07:20:15+00:00

(edit) – I was able to figure it out, in case anyone ever needs

  • 0

(edit) – I was able to figure it out, in case anyone ever needs it…

Just needed to add a few lines:

dim WSHShell, DesktopPath, objFSO

set objFSO=CreateObject("Scripting.FileSystemObject")
Set WSHshell = CreateObject("WScript.Shell")
DesktopPath = WSHShell.SpecialFolders("Desktop")

strWorkBook = (DesktopPath) & "\" & WshNetwork.ComputerName & "_" & WshNetwork.UserName & "-hardware.xls"

I’m sure this question will be no problem for one of you scripting guys. I’m sys admin so my scripting skills are not quite up to speed.

I have a vbs script which I’ve been hacking away on to take inventory of users PC’s using some defined criteria..

When executed, the script basically creates an Excel file, then gathers some info and writes to that file. My problem is that I have to specify a path for the xls output, currently it’s saving the file directly to the C:\ drive. For internal users, I’ve just been saving the file with a UNC path, but I need this for my external users who may not have access to the network.

I would like to have the path automagically set to the users profile like in a bat script ie: %UserProfile%\Desktop\somefolder

I’m just not that familier with .vbs is there an easy way to do this? Here is the script, you will probably notice some extra stuff in there, ignore that, it’s from the previous version of this script.

TLDR – How to make the path automatically set to users Desktop (Win XP and 7)?

As usual many, many thanks for reading and or answering!

Set WshNetwork = WScript.CreateObject("WScript.Network")

strComputer = "."

strWorkBook = "C:\" & WshNetwork.ComputerName & "_" & WshNetwork.UserName & "-hardware.xls"

' Create Excel Spreadsheet
strFileName = "C:\" & WshNetwork.ComputerName & "_" & WshNetwork.UserName & "-hardware.xls"
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
Set objWorkbook = objExcel.Workbooks.Add()
objWorkbook.SaveAs(strFileName)
objExcel.Quit
Set app = CreateObject("Excel.Application")
app.Workbooks.Open strWorkBook
Set wb = app.ActiveWorkbook
app.Visible = False
wb.Activate
Set ws = wb.Worksheets(1)
ws.Cells(1,1).Value = "System Name"
ws.Columns(1).ColumnWidth = 20

ws.Cells(1,2).Value = "Username"
ws.Columns(2).ColumnWidth = 30

ws.Cells(1,3).Value = "Main/Test System"
ws.Columns(3).ColumnWidth = 30

ws.Cells(1,4).Value = "Special Applications"
ws.Columns(4).ColumnWidth = 30

ws.Cells(1,5).Value = "Location of the system"
ws.Columns(5).ColumnWidth = 30

ws.Cells(1,6).Value = "Used by which department"
ws.Columns(6).ColumnWidth = 30

ws.Cells(1,7).Value = "if not DHCP / ip address"
ws.Columns(7).ColumnWidth = 30

ws.Cells(1,8).Value = "local admin rights"
ws.Columns(8).ColumnWidth = 30

ws.Cells(1,9).Value = "Operating System"
ws.Columns(9).ColumnWidth = 40

ws.Cells(1,10).Value = "Disk space available on hard drive"
ws.Columns(10).ColumnWidth = 20

ws.Cells(1,11).Value = "CPU"
ws.Columns(11).ColumnWidth = 30

ws.Cells(1,12).Value = "Total Memory"
ws.Columns(12).ColumnWidth = 20

ws.Cells(1,13).Value = "Manufacturer"
ws.Columns(13).ColumnWidth = 20

ws.Cells(1,14).Value = "Model"
ws.Columns(14).ColumnWidth = 20

ws.Cells(1,15).Value = "Serial Number"
ws.Columns(15).ColumnWidth = 30

ws.Rows(1).Font.Bold = True

' Get the serial number first to see if it already exists in the spreadsheet
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_BIOS",,48)
For Each objItem In colItems
strSerialNumber = "" & objItem.SerialNumber
Next
Set objWMIService = Nothing
Set colItems = Nothing

intRowToUse = -1
For intRowCount = 2 To ws.UsedRange.Rows.Count
      If Trim(strSerialNumber) = Trim(ws.Cells(intRowCount,5).Value) Then
            intRowToUse = intRowCount
      End If
Next
If intRowToUse = -1 Then
      intRowToUse = ws.UsedRange.Rows.Count + 1
End If

' Get Computer System Details
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_ComputerSystem",,48)
For Each objItem In colItems
    ws.Cells(intRowToUse,1).Value = "" & objItem.Caption 
    ws.Cells(intRowToUse,2).Value = "" & objItem.UserName
    ws.Cells(intRowToUse,13).Value = "" & objItem.Manufacturer
    ws.Cells(intRowToUse,14).Value = "" & objItem.Model
Next
Set objWMIService = Nothing
Set colItems = Nothing
'
'Output the Serial Number
ws.Cells(intRowToUse,15).Value = strSerialNumber

'
' Get CPU Details
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Processor",,48)
For Each objItem In colItems
    ws.Cells(intRowToUse,11).Value = "" & objItem.Name 
Next
Set objWMIService = Nothing
Set colItems = Nothing
'
' Get C: free space
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_LogicalDisk where DeviceID='c:'",,48)
For Each objItem In colItems
        ws.Cells(intRowToUse,10).Value = "" & FormatNumber(objItem.FreeSpace/1024/1024/1024,0) & "GB"
Next
Set objWMIService = Nothing
Set colItems = Nothing
'
' Get OS Details
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem",,48)
For Each objItem In colItems
    ws.Cells(intRowToUse,9).Value = "" & objItem.Caption
    ws.Cells(intRowToUse,12).Value = "" & FormatNumber(objItem.TotalVisibleMemorySize/1024/1024,0) & "GB"  
Next
Set objWMIService = Nothing
Set colItems = Nothing
'
' Get & Writeout current Date
'ws.Cells(intRowToUse,12).value = "" & Month(Now) & "-" & Day(Now) & "-" & Year(Now)

'Autofit all columns
app.ActiveSheet.Columns.EntireColumn.AutoFit
' Save Audit File
app.DisplayAlerts = False
'wb.Saved = True
wb.Close True
app.DisplayAlerts = False
app.quit

MsgBox "Done"
'=====================
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T07:20:16+00:00Added an answer on May 24, 2026 at 7:20 am

    Just needed to add a few lines

    dim WSHShell, DesktopPath, objFSO
    
    set objFSO=CreateObject("Scripting.FileSystemObject")
    Set WSHshell = CreateObject("WScript.Shell")
    DesktopPath = WSHShell.SpecialFolders("Desktop")
    
    strWorkBook = (DesktopPath) & "\" & WshNetwork.ComputerName & "_" & WshNetwork.UserName & "-hardware.xls"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

edit #2: Question solved halfways. Look below As a follow-up question, does anyone know
Edit ok, great feedback here, got me pointed in the right direction. Use case
Edit: I just moved my HTTPRequest code into the onCreate, and now all of
Edit 4: I was finally able to solve my own issue. See checkmark answer
Edit: I posted the whole class (striped a few for the error irrelevant things
EDIT: Reworked my code a bit and decided to throw out URLLoader in favor
Edit: this is NOT the same as ProgressDialog doesn't show just flashes I make
Edit: This question was written in 2008, which was like 3 internet ages ago.
Edit: From another question I provided an answer that has links to a lot
EDIT: This was formerly more explicitly titled: - Best solution to stop Kontiki's KHOST.EXE

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.