hispeed_mike Posted January 2, 2006 Share Posted January 2, 2006 FileOpen("\\comptername\ADMIN$\folder\readme.txt") WinWaitActive("Enter Password") Send("administrator") Send("{TAB}") Send("Password") Send("{ENTER}") Getting Error on Running which says Error: Incorrect number of parameters in function call... What I am wanting to do is connect to a file in an XP Pro's ADMIN$ share and execute it so it may run commands locally on that machine. Only found one formu on something similar but they didn't answer him. Help Appreciated. Thanks Mike Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted January 2, 2006 Moderators Share Posted January 2, 2006 (edited) You need to specify the mode for the FileOpen() to run the file as. Straight from the help file.FileOpen ( "filename", mode ) Mode (read or write) to open the file in. Can be a combination of the following: 0 = Read mode 1 = Write mode (append to end of file) 2 = Write mode (erase previous contents) 4 = Read raw mode 8 = Create directory structure if it doesn't exist (See Remarks). Both write modes will create the file if it does not already exist but a non existent folder (except using mode '8' - See Remarks).However that isn't going to give you the outcome you are wanting. That command is just for opening a file to be read or edited by the script itself. Being a Network Administrator I execute remote commands on computers several times a day. The best way I have found to do this is with a program called BeyondExec. I write a script to accomplish what I'm wanting on the computer, then push it with BeyondExec.Here is an example of how I would use it. I created a script that will configure an computers DNS Numbers based on its IP Address. I compile it and put it in my scripts dir (C:\Scripts). I also have the BeyondExec.exe copied to the root of C:\. So to push it to a computer I would use a command like this from the command prompt.c:\beyondexecv2.exe \\computername -C -I "C:\Scripts\DNS_Config.exe"-C = Copy the file to the remote computer before execution.-I = Allows the program to interact with the desktop. Edited January 2, 2006 by big_daddy Link to comment Share on other sites More sharing options...
hispeed_mike Posted January 2, 2006 Author Share Posted January 2, 2006 You need to specify the mode for the FileOpen() to run the file as. Straight from the help file. FileOpen ( "filename", mode ) Mode (read or write) to open the file in. Can be a combination of the following: 0 = Read mode 1 = Write mode (append to end of file) 2 = Write mode (erase previous contents) 4 = Read raw mode 8 = Create directory structure if it doesn't exist (See Remarks). Both write modes will create the file if it does not already exist but a non existent folder (except using mode '8' - See Remarks). However that isn't going to give you the outcome you are wanting. That command is just for opening a file to be read or edited by the script itself. Being a Network Administrator I execute remote commands on computers several times a day. The best way I have found to do this is with a program called BeyondExec. I write a script to accomplish what I'm wanting on the computer, then push it with BeyondExec. Here is an example of how I would use it. I created a script that will configure an computers DNS Numbers based on its IP Address. I compile it and put it in my scripts dir (C:\Scripts). I also have the BeyondExec.exe copied to the root of C:\. So to push it to a computer I would use a command like this from the command prompt. c:\beyondexecv2.exe \\computername -C -I "C:\Scripts\DNS_Config.exe" -C = Copy the file to the remote computer before execution. -I = Allows the program to interact with the desktop. Thanks for the tip... Just so I get this straight What I am eventually trying to do is to place a script into each of the machines which will check if IE is running. If it is not it will kill another program running then run an update to that program by downloading the update to a specified folder inside the ADMIN$ share folder(Windows..Da). Never tried anything this complex before but the first part of this process is to write an app which will connect to the 18 computers in question and to start the update (will need to do this with elavated privaliges). This first executable will be sitting on network storage and NOT on a PC wich I can access command prompt... Can I still run use this app or any suggestions? Thanks Mike Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted January 2, 2006 Moderators Share Posted January 2, 2006 (edited) What I am eventually trying to do is to place a script into each of the machines which will check if IE is running. If it is not it will kill another program running then run an update to that program by downloading the update to a specified folder inside the ADMIN$ share folder(Windows..Da).Okay, this doesn't seem to hard. Is this update going to change for each computer, or can you download the update and put it on a network share also? Never tried anything this complex before but the first part of this process is to write an app which will connect to the 18 computers in question and to start the update (will need to do this with elavated privaliges). This first executable will be sitting on network storage and NOT on a PC wich I can access command prompt... You can specify multiple computers with the app I provided a link to. Also if you have domain admin privaliges with the account you run the beyondexec from it will run on the other computers with those same privaliges. You can also run an executable from a network share. Where computers.grp is a plain text file, each line containing a different computer name. c:\beyondexecv2.exe -g computers.grp -C -I \\Server\Path\MyApp.exe If you can answer the questions I can help you better. Edited January 2, 2006 by big_daddy Link to comment Share on other sites More sharing options...
hispeed_mike Posted January 2, 2006 Author Share Posted January 2, 2006 (edited) Okay, this doesn't seem to hard. Is this update going to change for each computer, or can you download the update and put it on a network share also? The Update will be downloaded from an FTP Server and is the same for each PC... You can specify multiple computers with the app I provided a link to. Also if you have domain admin privaliges with the account you run the beyondexec from it will run on the other computers with those same privaliges. You can also run an executable from a network share. It will run from a network storage and I would say I will then have to automate putting in the administrators username and password or specify it as part of the command line and these PC's are only part of a workgroup NOT a Domain. Where computers.grp is a plain text file, each line containing a different computer name. c:\beyondexecv2.exe -g computers.grp -C -I \\Server\Path\MyApp.exe If you can answer the questions I can help you better. Thanks for working this through with me... Mike Edited January 2, 2006 by hispeed_mike Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted January 3, 2006 Moderators Share Posted January 3, 2006 The Update will be downloaded from an FTP Server and is the same for each PC...With this being the case I would download it to a network share and run the upgrades from there. It will run from a network storage and I would say I will then have to automate putting in the administrators username and password or specify it as part of the command line and these PC's are only part of a workgroup NOT a Domain.You can specify a username and password with beyondexec. I believe the syntax would look something like this: Where Administrator is the local admin account for the computer, and password is of course the password. c:\beyondexecv2.exe -G computers.grp -U Administrator -P password -C -I \\Server\Path\MyApp.exe Let us know if you need more help. Link to comment Share on other sites More sharing options...
hispeed_mike Posted January 3, 2006 Author Share Posted January 3, 2006 My last and defining question on this so I under stand. Can I use the command you specified below in and autoit script? Would this mean then that it would call the beyondexec application on the target computer or would this be part of the autoit script? I understand the app and running from the command line just not running from a computer but from a network share how this would call beyondexec... Really appreciate the headsup.... Mike With this being the case I would download it to a network share and run the upgrades from there. You can specify a username and password with beyondexec. I believe the syntax would look something like this: Where Administrator is the local admin account for the computer, and password is of course the password. c:\beyondexecv2.exe -G computers.grp -U Administrator -P password -C -I \\Server\Path\MyApp.exe Let us know if you need more help. Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted January 3, 2006 Moderators Share Posted January 3, 2006 My last and defining question on this so I under stand. Can I use the command you specified below in and autoit script?Yes, just run it like this: RunWait(@COMSPEC & " /c c:\beyondexecv2.exe -G computers.grp -U Administrator -P password -C -I \\Server\Path\MyApp.exe") Would this mean then that it would call the beyondexec application on the target computer or would this be part of the autoit script?The purpose of beyondexec is to be able to spawn the script on a remote computer. So your going to build your script that will update the computers, throw that out on a network share that all the computers can access. Then by using beyondexec from the command line on your computer, you are going to execute that script on the remote computers. I understand the app and running from the command line just not running from a computer but from a network share how this would call beyondexec...Hopefully my last comment answered this? Link to comment Share on other sites More sharing options...
hispeed_mike Posted January 4, 2006 Author Share Posted January 4, 2006 Gotcha.... You have been super.... perseverance and patience will win the day... Gratis Mike Yes, just run it like this: RunWait(@COMSPEC & " /c c:\beyondexecv2.exe -G computers.grp -U Administrator -P password -C -I \\Server\Path\MyApp.exe") The purpose of beyondexec is to be able to spawn the script on a remote computer. So your going to build your script that will update the computers, throw that out on a network share that all the computers can access. Then by using beyondexec from the command line on your computer, you are going to execute that script on the remote computers. Hopefully my last comment answered this? Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted January 4, 2006 Moderators Share Posted January 4, 2006 Glad I could be of help, let me know how it works for ya. 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