Jump to content

I'm trying to create a AutoIt script to use in SCCM to install AutoCad2023


Recommended Posts

I have to create an Application in SCCM for AutoCad2023 to install on our computer labs at the university, but AutoCad2023 does not install well with SCCM System user. If I copy the install.bat to the local computer and run it as a logged in Admin user it installs fine.  I'm trying to see if I can write a AutoIt script to Create an Admin user, Create a Directory,  Copy the Install.bat file to that new Directory, and then run the .bat file as the new local Admin user. After it installs - which takes 20 to 30 min. I'd like to remove the file, the directory and the temp local admin user.    This will be on Window 10.  Any assistance would be greatly appreciated!  This is my first attempt at scripting with AutoIt and I'm just putting pieces I'm finding together at this time - Thanks Doug

 

Here is what I have so far,

 

#include <AutoItConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIError.au3>
#include <GUIConstants.au3>

; Code to add user on local computer

$objSystem = ObjGet("WinNT://localhost")
$objUser = $objSystem.Create("user", $strUserName)
$objUser.FullName = "AutoDesk2023"
$objUser.SetPassword ("password")
$objUser.SetInfo
$objGroup = ObjGet("WinNT://localhost/Administrators")
$objGroup.Add("WinNT://"&$strUserName)

; Code to create directory on local computer

DirCreate("C:\AutoDesk2023Temp")

; Code to copy InstallAutoCad2023.bat to new Directory on local computer from server

#RequireAdmin
FileCopy(@ScriptDir & " Do I need to include server path where file exists? \InstallAutoCad2023.bat", "C:\AutoDesk2023Temp", 9)


; Use the username and password to execute file

    Local $sUserName = "AutoDesk2023"
    Local $sPassword = "password"
    Local $sDirectory = "C:\AutoDesk2023Temp\"
    Local $sFiletoRun = "InstallAutoCad2023.bat"

RunAsWait ($sUserName, @ComputerName, $sPassword, 0, $sDirectory & $sFiletoRun)
 

Edited by brantzdr
Link to comment
Share on other sites

Starting to fix this - So far this part works
 

RunWait('net user username password /add /fullname:"autoDesk2023" /expires:never /passwordchg:no') ; create the user account and set the password, don't allow it to be changed by the user
RunWait('net localgroup administrators autoDesk2023 /add') ; add the account to the administrators group

; Code to create directory on local computer

DirCreate("C:\AutoDesk2023Temp")

 

Link to comment
Share on other sites

I'm stuck at trying to run the .bat file with the local admin account that was created - It just doesn't run - Thanks 

Local $sUserName = "Username"
Local $sPassword = "Password"

 RunAsWait($sUserName, @ComputerName, $sPassword, 2, "C:\InstallFolderTemp\Install.bat")

Link to comment
Share on other sites

Now I'm just stuck trying to run the .bat file locally  - Anyone able to help?  Nothing happens when I try to run this.

 

  Local $sUserName = "AutoDesk2023"
    Local $sPassword = "password"
    Local $sDirectory = "C:\AutoDesk2023Temp\"
    Local $sFiletoRun = "InstallAutoCad2023.bat"

RunAsWait ($sUserName, @ComputerName, $sPassword, 0, $sDirectory & $sFiletoRun)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...