Jump to content

Recommended Posts

Posted

Hi,

 

Trying to build a script to run SSMS as "run as", everything works perfect from the script editor, but when I compile it, it seems to stop after the first step and does not continue

 

Quote
Quote
#RequireAdmin
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Outfile=tryyyyyyyy.Exe
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
Global $ip='192.168.1.12'
Global $username = 'acdc\aga'
Global $pwd = 'Aa123456'

Run(@ScriptDir &'\System32\runas.exe /netonly /user:'& $username &' ssms')
WinWait("C:\Windows\System32\runas.exe")
sleep(1000)
ControlSend("C:\Windows\System32\runas.exe","","",$pwd,"")
Sleep(1000)
ControlSend("C:\Windows\System32\runas.exe","","","{ENTER}","")
WinActivate("Microsoft SQL Server Management Studio (Administrator)")
WinWait("Connect to Server")
Sleep(1000)
ControlSend("Connect to Server", "", "[CLASS:Edit; INSTANCE:1]", $ip & "{ENTER}")

 

 

any idea what could be the problem that it stops after the Run if I run it from command line?

 

Thanks

Posted (edited)

Hi.

1.) Your Run statement referes to "@scriptdir\system32\runas.exe" (and not  "@SystemDir\runas.exe")

I doubt, that this is really, what you really want?

2.) It might make a difference, weather you compile to 32 of 64bit

 

3.) Take a look at the different "System folders":

 

c:\windows\system32

vs.

c:\windows\SysWOW64

Try EnvGet("sysnative")

 

See this explanation: http://www.thewindowsclub.com/sysnative-folder-in-windows-64-bit

 

 

Regards, Rudi.

 

Edited by rudi

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

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
  • Recently Browsing   0 members

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