Solved

VScript or Bat Script to Register DLL File as Administrator

Posted on 2013-02-05
4
499 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
The viewer will learn how to count occurrences of each item in an array.
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…

737 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