r/vbscript • u/JamesMBaldwin • Apr 28 '21
Super n00b question: insert variable into text string
Hi, I'm sure this is super basic but I've done about 45 min of searching and for some reason I can't get this to work.
I'm trying to insert the device name into a string of text that's requesting information from the user of the computer. I'm new to the org and almost no documentation was done around who has what computers. This is what I've pieced together from various sites:
Set wshShell = CreateObject( "WScript.Shell" )
strComputerName = wshShell.ExpandEnvironmentStrings( "%COMPUTERNAME%" )
x=msgbox("This is a request from IT services: Can you please send an email to itsupport@org.com with the asset tag number on your computer and the computer name: &strComputerName" ,4096, "IT Support Request")
Obviously I'm trying to get the strComputerName to enter the computer name into the message, but I'm obviously doing something wrong. Any assistance would be GREATLY appreciated.
Thanks for helping a scriptbaby!
View all comments
Show parent comment
1
u/[deleted] Apr 29 '21
oh cool, thanks for your contribution.
'This part of the script retrieves the Service Tag Number from the Computer
Set colSMBIOS = objWMIService.ExecQuery ("Select * from Win32_SystemEnclosure")
For Each objSMBIOS in colSMBIOS
If objSMBIOS.SerialNumber = "" Then
ServiceTag = "No Service Tag Retrieved"
Else
ServiceTag = objSMBIOS.SerialNumber
End If
Next