Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBSCRIPT Asset Data Collection via User Input

Status
Not open for further replies.

Lqqker777

IS-IT--Management
Apr 16, 2007
10
US
OK I got it the way I want it to work, NOW! hehehe always a BUT or NOW...

I need the script to run if the string doesnt exist but if it does to not run. I have tried all day using registrykeyexist with no luck, any thoughts?

Heres the script so far:

Dim sh, v, r
Set sh = WScript.CreateObject("WScript.Shell")

v = Msgbox("Enter Asset Tag Number")
If v = 2 Then
wscript.quit
End if
r = inputbox("ASSET NUMBER")
If r = "empty" Then
sh.regwrite "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\lanmanserver\parameters\AbbottAsset\Comment", "", "REG_SZ"

Else

sh.regwrite "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\lanmanserver\parameters\AbbottAsset\Comment", "", "REG_SZ"
sh.regwrite "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\lanmanserver\parameters\AbbottAsset\Comment", r, "REG_SZ"

End if
msgbox "Asset Tag Information has been entered, Thank You!" ,0, "Finished"

 
I need the script to run if the string doesnt exist

Which string? Please be more specific.

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\lanmanserver\parameters\AbbottAsset\Comment

or

Its value

If one or the other exist I want the script to do nothing... no popup just be totally silent.

Thanks for the response
Mark
 
use On Error Resume Next to allow for error trapping.

Do a registry read of the key.

If Err.Number = 0 Then
wscript.quit
Else
'rest of code to execute
End If

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Thanks for the response...

The registry read is the part I cant seem to get to work...
 
???? Im drawing a blank asto whats next....


Option Explicit
Dim WSHShell, RegKey, AbbottAsset, Result, v, r
Set WSHShell = CreateObject("WScript.Shell")
RegKey = "HKLM\SYSTEM\CurrentControlSet\Services\lanmanserver\parameters\AbbottAsset\"
AbbottAsset = WSHShell.RegRead (regkey & "CommentActive")
If AbbottAsset = 1 Then 'Abbott Asset is Enabled



If Err.Number = 0 Then
wscript.quit
Else


v = Msgbox("Please locate and enter the Abbott Asset Tag Number of this computer.")
v = Msgbox("TEXT 2")
v = Msgbox("TEXT 3")
If v = 2 Then
wscript.quit
End if
r = inputbox("Please enter Abbott Asset Tag Number below")
If r = "empty" Then
sh.regwrite "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\lanmanserver\parameters\AbbottAsset\Comment", "", "REG_SZ"

Else

sh.regwrite "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\lanmanserver\parameters\AbbottAsset\Comment", "", "REG_SZ"
sh.regwrite "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\lanmanserver\parameters\AbbottAsset\Comment", r, "REG_SZ"

End if
msgbox "Asset Tag Information has been entered, Thank You!" ,0, "Finished"


End If
End If
 
With the above nothing happens, I guess Ive over thought it to much and now im brain fried.
 
Code:
Option Explicit
[red]On Error Resume Next[/red]
Dim WSHShell, RegKey, AbbottAsset, Result, v, r
Set WSHShell = CreateObject("WScript.Shell")
RegKey = "HKLM\SYSTEM\CurrentControlSet\Services\lanmanserver\parameters\AbbottAsset\"
AbbottAsset = WSHShell.RegRead (regkey & "CommentActive")
[s]If AbbottAsset = 1 Then 'Abbott Asset is Enabled[/s]
If Err.Number = 0 Then 
   wscript.quit

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Here is the final script, I think everything is correct. It writes, It verifies... The only part im leary about is the following

Dim WSHShell, RegKey, AbbottAsset, Result
Dim sh, v, r
Set sh = WScript.CreateObject("WScript.Shell")
Set WSHShell = CreateObject("WScript.Shell")

____________________________________________________________

Option Explicit
On Error Resume Next
Dim WSHShell, RegKey, AbbottAsset, Result
Dim sh, v, r
Set sh = WScript.CreateObject("WScript.Shell")
Set WSHShell = CreateObject("WScript.Shell")
RegKey = "HKLM\SYSTEM\CurrentControlSet\Services\lanmanserver\parameters\AbbottAsset\"
AbbottAsset = WSHShell.RegRead (regkey & "Comment")

If Err.Number = 0 Then
wscript.quit
Else

v = Msgbox("Please locate and enter the Abbott Asset Tag Number of this computer.")
v = Msgbox("TEXT 2")
v = Msgbox("TEXT 3")
If v = 2 Then
wscript.quit
End if
r = inputbox("Please enter Abbott Asset Tag Number below")
If r = "empty" Then
sh.regwrite "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\lanmanserver\parameters\AbbottAsset\Comment", "", "REG_SZ"

Else

sh.regwrite "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\lanmanserver\parameters\AbbottAsset\Comment", "", "REG_SZ"
sh.regwrite "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\lanmanserver\parameters\AbbottAsset\Comment", r, "REG_SZ"

End if
msgbox "Asset Tag Information has been entered, Thank You!" ,0, "Finished"

End If
 
These two lines are the same:

Set sh = WScript.CreateObject("WScript.Shell")
Set WSHShell = CreateObject("WScript.Shell")

Use sh or WSHShell throughout the script and get rid fo the extra line.

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
These two lines are the same:

Set sh = WScript.CreateObject("WScript.Shell")
Set WSHShell = CreateObject("WScript.Shell")

Use sh or WSHShell throughout the script and get rid fo the extra line.

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top