Jump to content

Help with passing password from one script to another


Recommended Posts

I have one script on a server that has the runas for the elevated rights for our script.

What I want to do is pass the out put from that script into another script so that script runs the program with the elevated rights from the first script.

This is my password script

;

;AutoIT Script created by Scott MIller 5/16/07

;

;Runs elevated rights while running the printer install script; The printer script calls this file

;

;

$user = "username"

$domain = "domain"

$password = "password"

RunAsSet($user, $domain, $password, 0)

IniWrite("\\opc-sms01\ScriptShare\pw.ini", "username", "value1", "username")

IniWrite("\\opc-sms01\ScriptShare\pw.ini", "domain", "value2", "domain")

IniWrite("\\opc-sms01\ScriptShare\pw.ini", "password", "value3", "password")

This is my program script

;

;AutoIT Script created by Scott MIller 5/16/07

;

;Runs the VB scripts that came with Windows XP to create a local printer port, copy the printer drivers, and then create the local printer

;

;

;Runs external script containing the username, password, and domain for elevated rights

$source1 = "\\opc-sms01\ScriptShare"

$app1 = $source1 & "\NetPrinterPW.exe"

Run($app1, $source1)

Sleep(10000)

$user = IniRead("\\opc-sms01\ScriptShare\pw.ini", "username", "value1", "NotFound")

$domain = IniRead("\\opc-sms01\ScriptShare\pw.ini", "domain", "value2", "NotFound")

$password = IniRead("\\opc-sms01\ScriptShare\pw.ini", "password", "value3", "NotFound")

RunAsSet($user, $domain, $password, 0)

;Runs the printer setup exe to install the printer

$source = "\\opc-fnetprod\Printers and Copiers\New Castle\NEW1DSM716SPA"

$app = $source & "\risetup.exe"

Run($app, $source)

;Clicks the buttons for the user to install the printer

$title = "Add Printer and Utility Wizard"

$text = "Available Softwares"

$button1 = "I &accept the agreement."

$button2 = "&Next >"

WinWait($title, $text)

ControlClick($title, $text, $button1)

ControlClick($title, $text, $button2)

;Clicks the buttons for the user if a printer with this name exists

$title = "Install Printer Driver"

$text = "Another printer already has this name."

$button1 = "OK"

WinWait($title, $text, 3)

ControlClick($title, $text, $button1)

;Selects no to reboot and then clicks finish

$title = "Add Printer and Utility Wizard"

$text = "Software installation is completed."

$button1 = "No. Restart later."

$button2 = "&Finish"

WinWait($title, $text)

ControlClick($title, $text, $button1)

ControlClick($title, $text, $button2)

FileDelete("\\opc-sms01\ScriptShare\pw.ini")

;Notifies the user that the printer was installed

$title = "Printer Install"

$text = "Your Printer Is Now Installed" & @CRLF & "Press ok to continue"

MsgBox(0, $title, $text)

What I want to do is call a function from the first script with the username and password information into the second script and I have no idea how to do this.

Thanks You,

Scott

Link to comment
Share on other sites

I have one script on a server that has the runas for the elevated rights for our script.

What I want to do is pass the out put from that script into another script so that script runs the program with the elevated rights from the first script.

This is my password script

;

;AutoIT Script created by Scott MIller 5/16/07

;

;Runs elevated rights while running the printer install script; The printer script calls this file

;

;

$user = "username"

$domain = "domain"

$password = "password"

RunAsSet($user, $domain, $password, 0)

IniWrite("\\opc-sms01\ScriptShare\pw.ini", "username", "value1", "username")

IniWrite("\\opc-sms01\ScriptShare\pw.ini", "domain", "value2", "domain")

IniWrite("\\opc-sms01\ScriptShare\pw.ini", "password", "value3", "password")

This is my program script

;

;AutoIT Script created by Scott MIller 5/16/07

;

;Runs the VB scripts that came with Windows XP to create a local printer port, copy the printer drivers, and then create the local printer

;

;

;Runs external script containing the username, password, and domain for elevated rights

$source1 = "\\opc-sms01\ScriptShare"

$app1 = $source1 & "\NetPrinterPW.exe"

Run($app1, $source1)

Sleep(10000)

$user = IniRead("\\opc-sms01\ScriptShare\pw.ini", "username", "value1", "NotFound")

$domain = IniRead("\\opc-sms01\ScriptShare\pw.ini", "domain", "value2", "NotFound")

$password = IniRead("\\opc-sms01\ScriptShare\pw.ini", "password", "value3", "NotFound")

RunAsSet($user, $domain, $password, 0)

;Runs the printer setup exe to install the printer

$source = "\\opc-fnetprod\Printers and Copiers\New Castle\NEW1DSM716SPA"

$app = $source & "\risetup.exe"

Run($app, $source)

;Clicks the buttons for the user to install the printer

$title = "Add Printer and Utility Wizard"

$text = "Available Softwares"

$button1 = "I &accept the agreement."

$button2 = "&Next >"

WinWait($title, $text)

ControlClick($title, $text, $button1)

ControlClick($title, $text, $button2)

;Clicks the buttons for the user if a printer with this name exists

$title = "Install Printer Driver"

$text = "Another printer already has this name."

$button1 = "OK"

WinWait($title, $text, 3)

ControlClick($title, $text, $button1)

;Selects no to reboot and then clicks finish

$title = "Add Printer and Utility Wizard"

$text = "Software installation is completed."

$button1 = "No. Restart later."

$button2 = "&Finish"

WinWait($title, $text)

ControlClick($title, $text, $button1)

ControlClick($title, $text, $button2)

FileDelete("\\opc-sms01\ScriptShare\pw.ini")

;Notifies the user that the printer was installed

$title = "Printer Install"

$text = "Your Printer Is Now Installed" & @CRLF & "Press ok to continue"

MsgBox(0, $title, $text)

What I want to do is call a function from the first script with the username and password information into the second script and I have no idea how to do this.

Thanks You,

Scott

Maybe this works : works for me ( not tested on server )

Encrypt password

console write

console read

decrypt password

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...