Jump to content

Fun with batch files


Recommended Posts

The APPDIR= command line switch is for the NOD32 installation, it's not an AutoIt command, see the information here for more help. I don't know if it will affect anything in the install, but it's a place to start.

Have you tried using the ShellExecute command on eavbe_nt32_enu.msi instead of using a batch file to run it? Seeing as how your batch file is just one line that runs the command with the command line switches for it, you might be better off not using the batch file. How is this script being run, at log on, at start up, or while someone is using the computer? Is it being run from the computer you're trying to install the program on?

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

The APPDIR= command line switch is for the NOD32 installation, it's not an AutoIt command, see the information here for more help. I don't know if it will affect anything in the install, but it's a place to start.

Have you tried using the ShellExecute command on eavbe_nt32_enu.msi instead of using a batch file to run it? Seeing as how your batch file is just one line that runs the command with the command line switches for it, you might be better off not using the batch file. How is this script being run, at log on, at start up, or while someone is using the computer? Is it being run from the computer you're trying to install the program on?

It's going to be run at logon, also, ShellExecute doesn't allow for my username and password

Edited by Knoffelstokkie
Link to comment
Share on other sites

ok, now this is weird, I got it working but only if I change the location of the nod install files

If I point it to a mapped drive then nothing runs after the mapping happens

If I point it to c:\

Runas( "username","domain","pass",0,"c:\nod32\nod32.bat","c:\nod32" )

then it works just fine

Link to comment
Share on other sites

You might need to allow time for the drive mapping to connect before executing the command on it. Considering the fact that you map the drive then immediately try to run a command on it, it may be that it's failing because the drive doesn't exist yet. For a test, try adding a couple of seconds delay in between the DriveMapAdd command and the RunAs command with a Sleep(5000) for a 5 second delay. It shouldn't take 5 seconds to map a drive, but this is just for a test.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

You might need to allow time for the drive mapping to connect before executing the command on it. Considering the fact that you map the drive then immediately try to run a command on it, it may be that it's failing because the drive doesn't exist yet. For a test, try adding a couple of seconds delay in between the DriveMapAdd command and the RunAs command with a Sleep(5000) for a 5 second delay. It shouldn't take 5 seconds to map a drive, but this is just for a test.

nope, still doing the same

drive maps successfully and then nothing... ;)

Link to comment
Share on other sites

Well, the only thing I can think of is to copy the file to the C: drive and run it from there for now, at least until you work out why it won't work on a network drive. You can always delete the file after the script ends to clean up after.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Well, the only thing I can think of is to copy the file to the C: drive and run it from there for now, at least until you work out why it won't work on a network drive. You can always delete the file after the script ends to clean up after.

I also thought of that but it's 800 pc's, won't go down well if I copy 35mb / pc to 800 of them ;)

Edited by Knoffelstokkie
Link to comment
Share on other sites

Instead of mapping the drive "W:", try using this instead to run your batch file

RunAs("username","domain", "pass",0,"\\servername\share\nod32.bat", @tempdir )

See if that does anything different.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

I got the idea for the fix from Microsoft's support site and thought it might apply here as well.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

I got the idea for the fix from Microsoft's support site and thought it might apply here as well.

Awesome, but now I'm stuck again ;)

I want it to check if it's already installed and then not run the file

I got this from the web

If FileExists (@ProgramFilesDir &"\\ESET\ESET NOD32 Antivirus\SysInspector.exe") Then

Exit

EndIf

but it tells me I have the following syntax error

ERROR: multi-line 'If' missing 'Then'.

which I don't get because the then is obviously there

Edited by Knoffelstokkie
Link to comment
Share on other sites

You could just write that line like this instead:

If FileExists('"' & @ProgramFilesDir & "\ESET\ESET NOD32 Antivirus\SysInspector.exe"& '"') Then Exit

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

If you're running the script from your own machine, that's where @ProgramFilesDir is looking, right? Maybe you don't have NOD32 installed on your local machine, so the script doesn't exit?

If you want to look for the file on the remote user's machine, you'll likely have to specify the path to the remote drive in the FileExists argument. The destructions say you can use FileExists to check for the existence of a directory, too. So if someone has a non-standard Program Files directory you could spit the fact that the check on their machine failed to a log so you can go back and handle it separately later.

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