Solved

VScript or Bat Script to Register DLL File as Administrator

Posted on 2013-02-05
4
482 Views
Last Modified: 2013-02-28
I need help registering  a dll file as administrator.  I can right click the cmd and then "Run as Administrator".  This would allow me to register, however, my issue is that I need to register this for over 100+ PC.

So I need help to do this as a login script.  Normally this is how I would register the dll file.

This is for 64-bit OS:
C:\Windows\SysWOW64\Regsvr32.exe "\\serverA1\ERP\sscvix.dll"

This is for 32-bit OS:
C:\Windows\System32\Regsvr32.exe "\\serverA1\ERP\sscvix.dll"


So need help with determining which OS is on that PC as well as registering that dll file as administrator.  Any ideas?
0
Comment
Question by:holemania
  • 2
4 Comments
 
LVL 16

Expert Comment

by:choward16980
Comment Utility
Below I've pasted Oberwald's solution for a VBS that runs batch file as elevated.
http://social.technet.microsoft.com/Forums/eu/ITCG/thread/310e57f9-2367-4293-9f97-53d0e077aacc

Here is a script that forces UAC elevation:
'---------------------------------------
'Elevate this script before invoking it.
'25.2.2011 FNL
'---------------------------------------
bElevate = False
if WScript.Arguments.Count > 0 Then If WScript.Arguments(WScript.Arguments.Count-1) <> "|" then bElevate = True
if bElevate Or WScript.Arguments.Count = 0 Then ElevateUAC
'******************
'Your script goes here
'******************

'-----------------------------------------
'Run this script under elevated privileges
'-----------------------------------------
Sub ElevateUAC
    sParms = " |"
    If WScript.Arguments.Count > 0 Then
            For i = WScript.Arguments.Count-1 To 0 Step -1
            sParms = " " & WScript.Arguments(i) & sParms
        Next
    End If
    Set oShell = CreateObject("Shell.Application")
    oShell.ShellExecute "wscript.exe", WScript.ScriptFullName & sParms, , "runas", 1
    WScript.Quit
End Sub
0
 
LVL 16

Expert Comment

by:choward16980
Comment Utility
Have you looked at the RUNAS command in Vista and WIndows 7?  It's probably more suited to what you're looking for.  The only problem is if you used a batch file for this, you'll need to put an admin level password plain text inside it.  This will require you to give your users execute NTFS permissions and remove read NTFS permission.
Untitled.png
0
 
LVL 65

Accepted Solution

by:
RobSampson earned 500 total points
Comment Utility
Hi, on your \\serverA1\ERP\sscvix.dll file, grant Domain Computers read rights, then try running this script as a "Startup script" instead of a login script.

Regards,

Rob.

strComputer = "."
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

strArchitecture = GetOSArchitecture(objWMIService)

Set objShell = CreateObject("WScript.Shell")

If strArchitecture = 32 Then
	objShell.Run "C:\Windows\System32\Regsvr32.exe /s ""\\serverA1\ERP\sscvix.dll""", 0, True
Else
	objShell.Run "C:\Windows\SysWOW64\Regsvr32.exe /s ""\\serverA1\ERP\sscvix.dll""", 0, True
End If

Function GetOSArchitecture(objRemote)
	' TITLE: GetOSArchitecture
	' DESCRIPTION: This function will use a WMI query to determine the system
	'	architecture of the target computer
	' INPUT:
	'	objRemote must be an object that is bound to the WMI service on the target machine
	'	Make a call such as Set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
	'	and pass objWMI to this function
	' OUTPUT:
	'	A string value being 32 or 64
	Set colOS = objRemote.ExecQuery("SELECT OSArchitecture FROM Win32_OperatingSystem",, 48) 
    For Each objOS In colOS 
        intAddressWidth = objOS.OSArchitecture
    Next
    If intAddressWidth = "32-bit" Then intAddressWidth = 32
    If intAddressWidth = "64-bit" Then intAddressWidth = 64
    GetOSArchitecture = intAddressWidth
End Function

Open in new window

0
 

Author Closing Comment

by:holemania
Comment Utility
Thank you.
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

728 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

9 Experts available now in Live!

Get 1:1 Help Now