Solved

Assistance getting a vbscript to run as a local administrator.

Posted on 2008-10-20
2
445 Views
Last Modified: 2008-11-05
Hello. I created a script that installs Bluetooth software, moves files and folders. It also creates several registry keys.

I was hoping to get some assistance with running it as a local administrator. I am deploying the package through SMS and it request the local administrator password to complete the script.

Is it possible to run the entire script as a local administrator?
Option Explicit
 

'Set Variables

Dim strComputer

Dim oReg

Dim strKeyPath

Dim strApp

Dim strAppValue

Dim strDate

Dim strDateValue

Dim strInstalled

Dim strInstalledValue

Dim strVersion

Dim strVersionValue

Dim Install

Dim WshShell

Dim objFSO

Dim objFolder

Dim colItems

Dim objItem

Dim objShell
 

'Installation of Bluetooth software

Set objFSO = CreateObject("Scripting.FileSystemObject")

Set WshShell = WScript.CreateObject("WScript.Shell")

Install = WshShell.Run ("Msiexec.exe /i  BtSwInst.msi /qb! REBOOT=ReallySuppress SECURITY=TosBtUtlver2.ini /l* C:\windows\logs\Bluetooth_6.01.03D_P5.log", 1, TRUE)
 

'Move folders

Set objFSO = CreateObject("Scripting.FileSystemObject")

objFSO.MoveFolder "c:\Documents and Settings\All Users\Start Menu\Programs\Bluetooth" , "c:\Documents and Settings\All Users\Start Menu\Utilities\Bluetooth"

objFSO.MoveFile "c:\Documents and Settings\All Users\Start Menu\Programs\Startup\Bluetooth Manager.lnk" , "c:\Documents and Settings\All Users\Start Menu\Utilities\Bluetooth\Bluetooth Manager.lnk"
 

'Disable device driver

Set objShell = CreateObject("WScript.Shell")

objShell.Run "update.Bat", 0, True
 

'Write Registry Keys

const HKEY_LOCAL_MACHINE = &H80000002

strComputer = "."
 

Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_ 

strComputer & "\root\default:StdRegProv")
 

strKeyPath = "SOFTWARE\Apps\CCP\Bluetooth_6.01.03D_P5"

oReg.CreateKey HKEY_LOCAL_MACHINE,strKeyPath
 

strKeyPath = "SOFTWARE\Apps\CCP\Bluetooth_6.01.03D_P5"

strApp = "AppName"

strAppValue = "Bluetooth_Software"

oReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strApp,strAppValue
 

strKeyPath = "SOFTWARE\Apps\CCP\Bluetooth_6.01.03D_P5"

strDate = "InstallDate"

strDateValue = Date & " - " & Time

oReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strDate,strDateValue
 

strKeyPath = "SOFTWARE\Apps\CCP\Bluetooth_6.01.03D_P5"

strInstalled = "InstallBy"

strInstalledValue = "SMS"

oReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strInstalled,strInstalledValue
 

strKeyPath = "SOFTWARE\Apps\CCP\Bluetooth_6.01.03D_P5"

strVersion = "Version"

strVersionValue = "6.01.03D"

oReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strVersion,strVersionValue

Open in new window

0
Comment
Question by:Lorrec
2 Comments
 
LVL 7

Accepted Solution

by:
Hubasan earned 500 total points
ID: 22760864
One of the main articles in the VB Scripting section of this site explains how to run any VB Script as local admin. Here is the link:

http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_22502969.html
0
 

Author Comment

by:Lorrec
ID: 22886848
Thanks
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Pull multiple cvs files into one access table 28 64
vb script  to start the services is not working 4 37
Check version 13 68
EXCEL: Random Select and Copy 10% of the Row 7 78
Hello again, all.  For those of you that have been following along, you'll know that this is my third article on this topic (though it is not Part III).  This article is sort of remedial, and probably the topic with which I should have started the s…
Welcome, welcome!  If you are new to the series and haven't been following along, please take a brief moment to review the first three installments: Part 1 (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/A_266-VBScri…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now