Run VBS with domains admin account

I have a Vbs that is ok when user is administrator of the machine, I need to run this script as domain admin.

I think in call this script or imput a account and password in this script.

The script is:

Set WshShell = WScript.CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Const OverWriteFiles = True
strTempDir = WshShell.ExpandEnvironmentStrings("%TEMP%")
strAppDataDir = WshShell.ExpandEnvironmentStrings("%APPDATA%")
strFirefoxProfilesDir = strAppDataDir & "\Mozilla\Firefox\Profiles"

'------------------------------------------------------

strCertutilFolder = "Network path"
strLocalCertificateAuthorityName = "FortiGate CA"
strCertificateFileName = "FortiGateCA.crt"
strTrustAttributes = "CT,c,C"

'------------------------------------------------------

If objFSO.FolderExists(strFirefoxProfilesDir) Then
  objFSO.CopyFolder strCertutilFolder, strTempDir & "\FirefoxTools", OverWriteFiles
  Set arrFirefoxProfileList = objFSO.GetFolder(strFirefoxProfilesDir).SubFolders
  For Each FireFoxProfile In arrFirefoxProfileList
    objFSO.CopyFile FireFoxProfile & "\cert8.db" , FireFoxProfile & "\cert8.db.old", OverWriteFiles
    Call WshShell.Run(strTempDir & "\FirefoxTools\certutil -A -n " & Chr(34) & strLocalCertificateAuthorityName & Chr(34) & " -i " & strTempDir & "\FirefoxTools\" & strCertificateFileName & " -t " & Chr(34) & strTrustAttributes & Chr(34) & " -d " & Chr(34) & FireFoxProfile & Chr(34), 0, true)
  Next
  objFSO.DeleteFolder(strTempDir & "\FirefoxTools")
End If

'------------------------------------------------------

Function IsInstalled(strSoftwareName)
  IsInstalled = FALSE 
  On Error Resume Next
  const HKEY_LOCAL_MACHINE = &H80000002
  Set colEnvironment = WshShell.Environment("PROCESS")
  If colEnvironment("ProgramFiles(x86)") <> "" Then
    arrWOW6432NODE= Array("WOW6432NODE\","")
  Else
    arrWOW6432NODE= Array("")
  End If
  For Each Wow6432Node In arrWOW6432NODE
    Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
    strKeyPath = "SOFTWARE\" & Wow6432Node & "Microsoft\Windows\CurrentVersion\Uninstall"
    objReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys
    For Each subkey In arrSubKeys
      InstalledSWName = WshShell.RegRead("HKLM\" & strKeyPath & "\" & subkey & "\DisplayName")
      If InStr(InstalledSWName, strSoftwareName) > 0 Then
        IsInstalled = TRUE 
        Exit For 
      End If
    Next
  Next
End Function

 
April 28th, 2015 3:39pm

Hi,

You can use RunAs to run the script as an admin.

You'll still need to type your pas

Free Windows Admin Tool Kit Click here and download it now
April 28th, 2015 3:43pm

But it is to all machines in network, I can not type a password, I need to imput on script.
April 28th, 2015 3:51pm

As noted, you cannot bypass the UAC prompt. This is by design.

You need to deploy your software using a software deployment tool.

Your question is outside the scope of this forum.

Free Windows Admin Tool Kit Click here and download it now
April 28th, 2015 3:58pm

You should use AD to distribute certificates.
April 28th, 2015 4:54pm

But to use AD just imput on Internet Explorer, I need to imput in Mozila Firefox, this script do it and just need to imput a admin account and password to run it.

Can help me?

Free Windows Admin Tool Kit Click here and download it now
April 29th, 2015 7:04am

But to use AD just imput on Internet Explorer, I need to imput in Mozila Firefox, this script do it and just need to imput a admin account and password to run it.

Can help me?

What you are claiming is impossible.  Certs are not stored in Firefox.  Firefox and other programs just use certs stored in the the NSS database which is global to the machine.  If an admin account is required then it is stored in the machine level store and can be distributed by Group Policy.

CERTUTIL can be run as a startup script without credentials and will install the cert for all users.  Place the command is a batch file and set as a startup script.

April 29th, 2015 8:41am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics