bshatford Posted June 4, 2008 Share Posted June 4, 2008 Hello all, This one is driving me crazy. I have been reading through the runas posts but can't seem to find one that matches my problem. Now please be patient with me as the scripting stuff is all new to me. I am attaching my code so you can see what I have done and see where I might have messed up. Basically, the script runs and when it tries to RunAs, it errors out. CODELocal $sUserName = "username" Local $sPassword = "password" Local $IONdir = "\\Distapps1vs\Distapps1vl\apps\ION Client\" Local $IONrem = "haspdinst.exe -fr -kp" Local $IONinst = "haspdinst.exe -i -kp" RunAs($sUserName, @ComputerName, $sPassword, 4, $IONrem, $IONdir) If @error <> 0 Then MsgBox(64, "HASPDINST.EXE", "Application Failed to run!!") Exit WinWaitActive("Aladdin HASP SRM Run-time Environment Installer v. 5.30") Send("{ENTER}") Sleep (5000) EndIf RunAs($sUserName, @ComputerName, $sPassword, 0, $IONinst, $IONdir) If @error <> 0 Then MsgBox(64, "HASPDINST.EXE", "Application Failed to run!!") Exit Else Sleep (10000) MsgBox(64, "Aladdin HASP SRM Run-time Environment Installer", "Fix Complete") EndIf Exit I removed the username and passwords to protect the innocent. Any help you can provide would be greatly appreciated. Bob Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 4, 2008 Share Posted June 4, 2008 (edited) Hello all, This one is driving me crazy. I have been reading through the runas posts but can't seem to find one that matches my problem. Now please be patient with me as the scripting stuff is all new to me. I am attaching my code so you can see what I have done and see where I might have messed up. Basically, the script runs and when it tries to RunAs, it errors out. CODELocal $sUserName = "username" Local $sPassword = "password" Local $IONdir = "\\Distapps1vs\Distapps1vl\apps\ION Client\" Local $IONrem = "haspdinst.exe -fr -kp" Local $IONinst = "haspdinst.exe -i -kp" RunAs($sUserName, @ComputerName, $sPassword, 4, $IONrem, $IONdir) If @error <> 0 Then MsgBox(64, "HASPDINST.EXE", "Application Failed to run!!") Exit WinWaitActive("Aladdin HASP SRM Run-time Environment Installer v. 5.30") Send("{ENTER}") Sleep (5000) EndIf RunAs($sUserName, @ComputerName, $sPassword, 0, $IONinst, $IONdir) If @error <> 0 Then MsgBox(64, "HASPDINST.EXE", "Application Failed to run!!") Exit Else Sleep (10000) MsgBox(64, "Aladdin HASP SRM Run-time Environment Installer", "Fix Complete") EndIf Exit I removed the username and passwords to protect the innocent. Any help you can provide would be greatly appreciated. Bob Is the executable located in the directory you have in $IONdir? You may need to fully path that: RunAs($sUserName, @ComputerName, $sPassword, 0, $IONdir & $IONinst, $IONdir) P.S. Or, take care of it at the top: Local $IONdir = "\\Distapps1vs\Distapps1vl\apps\ION Client\" Local $IONrem = $IONdir & "haspdinst.exe -fr -kp" Local $IONinst = $IONdir & "haspdinst.exe -i -kp" Either way... P.P.S. Ooh... DaveF makes a good point too. The UNC path may not be valid for the RunAs user environment. Edited June 4, 2008 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
DaveF Posted June 4, 2008 Share Posted June 4, 2008 A new RunAs environment doesn't inherit any network connections, so it wouldn't have any access to your network share. I'll typically use two EXEs for a task like this, a wrapper that simply calls RunAs on the other EXE (either FileInstall-ed or alongside), and the second EXE which establishes a network connection (with DriveMapAdd) and then performs the rest of the tasks. Yes yes yes, there it was. Youth must go, ah yes. But youth is only being in a way like it might be an animal. No, it is not just being an animal so much as being like one of these malenky toys you viddy being sold in the streets, like little chellovecks made out of tin and with a spring inside and then a winding handle on the outside and you wind it up grrr grrr grrr and off it itties, like walking, O my brothers. But it itties in a straight line and bangs straight into things bang bang and it cannot help what it is doing. Being young is like being like one of these malenky machines. Link to comment Share on other sites More sharing options...
bshatford Posted June 5, 2008 Author Share Posted June 5, 2008 I'll give that a shot. It may take me some time, but I should be able to figure it out. Just one question, do I need to #include my first file in the second one? Thank you for the info so far. It has really gotten my brain working. Bob Link to comment Share on other sites More sharing options...
bshatford Posted June 5, 2008 Author Share Posted June 5, 2008 Well, I have a working script. It doesn't work quite the way I'd originally planned, but it should get the job done. What I had to do was copy the files locally, then issue the RunAs command to the local copies. When it is complete, it removes the files from local drives. This seems to accomplish what I need it to do, but not quite how I'd envisioned it. I guess you have to be flexible when it comes to creating scripts. If you'd like to see what my final script looks like, just let me know and I'll post it. Thanks for your help Dave and Psalty. I really do appreciate it. Bob Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now