Jump to content

Multiple Dos Commands


Recommended Posts

The Code below is the complete code for what I am working on. I put it in for general tidying because I am still a novice and tips in general are welcome.

First the primary issue. A client uses a remote connection string to 'wrap' oracle programs so that all environmental variable are loaded in to memory and then dumped at the completion of a program. This file is remote (as in on a server elsewhere) and can be changed by the oracle Admins at any time. Most programs that need oracle are then Wrapped in a *.CMD file that loads the variables needed and then executes the program at the end (Start, foo, "Program Name").

My issue is this. I am protecting a single execution of the program with a password (simple protection). If the correct password is given the connection to the Oracle environment is established, else the program will not work. Simply executing the program will cause a failure because the Oracle environment will not be loaded. So I wanted to use an Auto-It script to prompt for the password and if the proper password is given execute the command information needed. I don't want to just execute an existing CMD file because the user could simply execute that file and run the program, bypassing auto-it completely. Technically a user could still manually try to set up an oracle environment, but that is not likely.

However, it seemed multiple uses of the Run command against various executions causes Auto-it to only temporarily write those values to memory (this was expected I just hoped it would not be the case) instead of holding the data until the completion of the script. It is for that reason at the end of the script the final function calls a command window, hides it, and sends all the needed commands to that window. This method works; however I would prefer a cleaner way of doing this. If anyone has any ideas or suggestions as to how to load this in to a single memory block that is executed with all variables set please let me know.

Keep in mind because of the location and changes of the command wrapper piece I can not simply copy it's functionality. The file is dynamically changing so I can only call the file.

-Any Ideas?

#include<GUICONSTANTS.AU3>
#include<Function_List.AU3>  ;Include for Function_List is functions that I parsed to bottom of script.

 

 

;Variables
$tLog = "C:\Program Files\ISI\ISIPublisher\Logs\PassFail.txt"
$setting = "123456a"
$pISI = ('{ASC 034}C{ASC 058}\Program Files\ISI\ISIPublisher\ISIPublisherAdmin.exe{ASC 034}{ENTER}')
$pWORA = Client Sensitive (path to CMD file to set Oracle settings)
$pSet = Client Sensitive (sets oracle home)

$pImage = ("C:\Program Files\ISI\ISIPublisher\images\ISIPublisher.JPG")

$pISIPath = (@ProgramFilesDir & "\ISI\ISIPublisher")
$gWinText = ("Admin Password")
$gPrompt = ("Please Enter the Admin Password for ISIPublisher Admin")

 


;Gui Setup
GuiCreate($gWinText,375,100,-1,-1)
GuiSetIcon($pISIPath & "\ISIPublisherAdmin.exe",0)

 

;Menu Setup
GuiCtrlCreateMenu("&Info"); Currently awaiting User Specs.

 

;Label Setup
GuiCtrlCreateLabel(">Please enter the Admin password for the Application ISIPublisher Admin<", 5, 5,400)

 

;Edit Box
$iPassInput = GuiCtrlCreateInput("", 50, 20,250,20,$ES_CENTER+$ES_PASSWORD)

 

;Buttons
$bDone = GuiCtrlCreateButton("Done", 50, 50, 50, 25, $BS_DEFPUSHBUTTON)
$bCancel = GuiCtrlCreateButton("Cancel", 250, 50, 50, 25)

 

;Set State
GuiSetState(@SW_SHOW)
GuiSetState($GUI_FOCUS)

 

While 1
 $msg = GUIGetMsg()
 Select
  Case $msg = $bDone
   $sIPass = GUICtrlRead($iPassInput)
   Select 
    Case $sIpass = ""
     msgbox(48,"Empty Password","Password can not be left blank," & @CRLF & "please input a password and try again.")
    case $sIpass = $setting
     guisetstate(@SW_HIDE)
     SplashImageOn("ISI Admin Start", $pImage)
     _ISIExecute()
     winwait("ISIPublisher - Ad","")
     Exit
    case $sIpass <> $setting & $sIpass <> ""
     _logging($tLog, "Invalid Connection: " & @Mon & "/" & @MDAY & "/" & @YEAR & " ---ID--- " & _
     @UserName)
     msgbox(48,"Invalid Login","Invalid Login!" & @CRLF & "Please see your local representive regarding the ISI Publisher Admin password.")
     ControlSetText($gWinText,"",$sIpass,"")
     ControlFocus($gWinText,"",$sIpass)
   EndSelect
  Case $msg = $bCancel
   msgbox(0,"Canceled","Execution canceled")
   Exit
  EndSelect
 If $msg = $GUI_EVENT_CLOSE Then ExitLoop
 Wend
 

;Primary Issue Below this Line!
Func _ISIExecute()
 Runwait(@ComSpec & ' /c Start "foo"',@SystemDir, @SW_HIDE)
 Winwait("foo","")
 WinSetState("foo","",@SW_HIDE)
 Controlsend("foo","","",$pWORA)
 Controlsend("foo","","",$pSET)
 ControlSend("foo","","",$pISI)
 Controlsend("foo","","",'exit{enter}')
EndFunc

;End Primary Issue

 

func _Logging($Log, $Comment)
 FileOpen($Log, 1)
 FileWriteLine($Log, $Comment & @CRLF)
 Fileclose($Log)
EndFunc

As an aside I notice that there was no normal way to send shift characters to a dos window. I tried {shiftdown};{shiftup} to get a : and I tried +; and even changed to mode 1 and used : itself. The only way I found to get it was to call the ASC character, again if there is a more efficient method I am all eyes.

"I have discovered that all human evil comes from this, man's being unable to sit still in a room. " - Blaise Pascal
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...