#154826 - 2006-01-09 02:26 PM
What am I doing wrong
|
clmowers
Fresh Scripter
Registered: 2006-01-09
Posts: 13
|
Hello, Im new to scripting and Im having problems with a script I wrote. What Im trying to do is copy a file to some computer and then run that program. The issue that Im having is I have both 98 and xp machine. I can get the program to copy to both machine but cant get it to run on the 98. The xp machine seem to be fine. Here is a copy of my script. Can someone take a look and see what Im doing wrong. Thanks
debug on
;------------------------------------------------------------------------------------------ ;Copies Stng259.exe to local computer and runs script. Then send log of scan to mas90 ;------------------------------------------------------------------------------------------
$Y = "%temp%\stng259.exe" Copy @ldrive + "\stng259.exe" "$Y" if @error = 0 ; goto "product" else shell "%comspec% /c echo copy of stng259.exe to @wksta on @date Failed >> \\mas90\scripts$\stinger.txt GOTO "END" Endif
: product If @producttype = "Windows XP Professional" goto "XP" else goto "w98" endif
:w98 $Y = "%temp%\start1.bat" Copy @ldrive + "\start1.bat" "$Y" If @error =0 Run "%temp%\start1.bat" Else shell "%comspec% /c echo copy of start1.bat to @wksta on @date Failed >> \\mas90\scripts$\stinger.txt GOTO "end1" ENDiF :end1 cookie exit
:XP $Y = "%temp%\start.bat" Copy @ldrive + "\start.bat" "$Y" If @error =0 Run "%temp%\start.bat" Else shell "%comspec% /c echo copy of start.bat to @wksta on @date Failed >> \\mas90\scripts$\stinger.txt GOTO "end" endif :end cookie1 exit
|
|
Top
|
|
|
|
#154827 - 2006-01-09 02:38 PM
Re: What am I doing wrong
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Don't have 98 to check round here so I'm working from memory, but you could try: Code:
Run "command.com /C "+%temp%+"\start1.bat"
|
|
Top
|
|
|
|
#154829 - 2006-01-09 03:47 PM
Re: What am I doing wrong
|
clmowers
Fresh Scripter
Registered: 2006-01-09
Posts: 13
|
OK Thanks I will give those a shoot and see what happens. Let you know how it works out. Does the rest of the script look ok?
|
|
Top
|
|
|
|
#154831 - 2006-01-09 04:44 PM
Re: What am I doing wrong
|
NTDOC
Administrator
   
Registered: 2000-07-28
Posts: 11634
Loc: Space
|
Quote:
Does the rest of the script look ok?
No, not really as we don't care for the use of GOTO, however if it's working for you and you're not quite at a level of scripting to script without it then that's what matters most. However you should work on learning a bit more then about scripting so that you can run this and even better scripts in the future.
Scripting can be a lot of fun and improve your productivity overall, so keep practicing.
|
|
Top
|
|
|
|
#154832 - 2006-01-09 08:55 PM
Re: What am I doing wrong
|
clmowers
Fresh Scripter
Registered: 2006-01-09
Posts: 13
|
Ok for some reason It is totally skipping over the 98 section. I have no clue what is going on. Basicly what is happening is if you run the script with debug on it is copying the file. It is then proceed to copy of the start batch file which is for the XP PCs and then trys to run that one. dosnt even look at the w98. And because in 98 you cant do the start/belownormal command it error out.Im totally lost now.
|
|
Top
|
|
|
|
#154835 - 2006-01-10 12:32 PM
Re: What am I doing wrong
|
clmowers
Fresh Scripter
Registered: 2006-01-09
Posts: 13
|
Thanks Mart. I will give both of those a shot and let you know. Just wondering, Mabey it is because I am a newbie at scripting,but whats wrong with the goto? No one seems to like that.
|
|
Top
|
|
|
|
#154837 - 2006-01-10 01:11 PM
Re: What am I doing wrong
|
clmowers
Fresh Scripter
Registered: 2006-01-09
Posts: 13
|
Ok That makes sense.It definitelymade it easy to figure out. I tried the script that you wrote and it works great. Both XP and 98 are up and running with stinger. Now if only I can get the boss to upgrade the 98 machines to xp. Can you write a script for that one. TBut thanks again mart.
|
|
Top
|
|
|
|
#154839 - 2006-01-10 03:13 PM
Re: What am I doing wrong
|
clmowers
Fresh Scripter
Registered: 2006-01-09
Posts: 13
|
One more thing, this is now making no sense to me. The script runs great. Im am now trying to copy the log file that stinger creates to my network drive so I can review the log. I tried reversing what I had with the copy and it doesn’t work. I have the scrip you posted with this
$d = “\\mas90\scripts$\logs” copy %temp%\stng259.txt $d
Also is there a book or something that would help me learn scripting
Thanks again
|
|
Top
|
|
|
|
#154841 - 2006-01-10 04:56 PM
Re: What am I doing wrong
|
clmowers
Fresh Scripter
Registered: 2006-01-09
Posts: 13
|
Ok Thanks and I will check out that Book
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 2220 anonymous users online.
|
|
|