Solved

VScript or Bat Script to Register DLL File as Administrator

Posted on 2013-02-05
4
488 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
ID: 38856024
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
ID: 38856038
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
ID: 38857269
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
ID: 38938579
Thank you.
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

This is pretty cool.  The purpose of this VB Script is to help you document where JAR (Java ARchive) files and specifically java class files are located so that you can address issues seen with a client or that you can speak intelligently with a dev…
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.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

778 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