Solved

Batch file hanging

Posted on 2003-11-12
17
1,311 Views
Last Modified: 2013-12-03
Hi,
I have written a batch file that seems to hang when run remotely via the "system" command or via CMD <batchfilename>.

My batch file uses command line winzip to compress a load of files, then calls winzip self extractor via command line to change the zip into a .exe.
When this batch file is run from a normal cmd window it runs perfectly, no gui is ever shown, all quick and proper.
When invoked remotely (from oracle to a C dll that runs the system command with the batch file name), it runs until it gets to the winzip self extractor bit then stops and hangs.

To put another way: if i write another batch file with one line in it "cmd <old batch file name>" and run that, then it hangs also ie puts an entry in the processes list and never finishes.

Does this point to an  environmental difference between going into a normal cmd window and running a batch file (and it working) and doing it via the CMD method (and it not working)????

Please Help!
0
Comment
Question by:mwoolger
  • 8
  • 8
17 Comments
 
LVL 16

Expert Comment

by:_nn_
ID: 9730713
>> Does this point to an  environmental difference between going into a normal cmd window and running a batch file

I don't think so, but there's probably something in your environment that tells cmd to stay open once its job is finished (not the case on my box here). Could you please test again your 'other' batch, but this time changing from "cmd <old batch file name>" to "cmd /c <old batch file name>" ? If it works as expected, I'd suggest trying to use something like system("cmd.exe /c zipit.cmd") in the C code.

HTH.
0
 

Author Comment

by:mwoolger
ID: 9730795
I have tested it with the following:

c:\winnt\system32\cmd.exe /c c:\<name>.bat

Same problem. doh! winzip self extractor process created and just sits there. its almost as if the self extractor program has launched a gui, even though it hasnt and doesnt need to.
0
 
LVL 16

Expert Comment

by:_nn_
ID: 9730854
So, it's the winzip executable that is hanging ? ...

For debugging purposes, could you add some lines at the beginning of the batch :

set > batch.log

and additionally if you're running 2K

echo %CD% >>batch.log

The idea is to try to locate the environmental differences.
0
 

Author Comment

by:mwoolger
ID: 9730898
The results of running the batch file in this remote way are as follows. presumably there is something here which is different from that of a normal cmd window??
ORACLE_SID=extproc
ALLUSERSPROFILE=C:\Documents and Settings\All Users
Classpath=C:\Plan_Dissemination\PD_Task_Generation;C:\Plan_Dissemination\PD_Task_Generation\arapi51.jar
CommonProgramFiles=C:\Program Files\Common Files
COMPUTERNAME=CMDEVDB
ComSpec=C:\WINNT\system32\cmd.exe
db_code=D:\CM-R4\Database\Oracle
db_make=D:\CM-R4\Database\Oracle\CMDEVDB
NUMBER_OF_PROCESSORS=1
OS=Windows_NT
Os2LibPath=C:\WINNT\system32\os2\dll;
Path=D:\Oracle\Ora81\bin;C:\Program Files\Oracle\jre\1.1.7\bin;C:\WINNT\system32;C:\WINNT;C:\WINNT\System32\Wbem;C:\Plan_Dissemination\PD_Task_Generation;C:\Program Files\WINZIP81;C:\Program Files\WinZip Self-Extractor
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH
PROCESSOR_ARCHITECTURE=x86
PROCESSOR_IDENTIFIER=x86 Family 15 Model 1 Stepping 2, GenuineIntel
PROCESSOR_LEVEL=15
PROCESSOR_REVISION=0102
ProgramFiles=C:\Program Files
PROMPT=$P$G
SystemDrive=C:
SystemRoot=C:\WINNT
TEMP=C:\WINNT\TEMP
TMP=C:\WINNT\TEMP
USERPROFILE=C:\Documents and Settings\Default User
windir=C:\WINNT
0
 
LVL 16

Expert Comment

by:_nn_
ID: 9730945
Hmm, looks like a permissions issue. I see no USERNAME and the USERPROFILE variable points to Default User. Strange...

Wild guess : it looks like the batch is started in some other context. I don't know the details of an Oracle install, but if it's a service which is running under a specific account, you might want to try to give that account enough rights over the files and directories which are to be manipulated...

Another suggestion : if you haven't done it yet, have some explicit cd commands in the batch just to make sure you are in the right directory.
0
 

Author Comment

by:mwoolger
ID: 9730971
this is a little bizarre as my batch file works up until the winzip self extracting line so by thatpoint it has already created files and run an exe (the winzip command to zip files up) so some permissions presumably exist.
what ones would be missing and how do i add them? its win2k.

in terms of directory, the winzip self extractor is in the path so its obviously finding it, and the batch file is invoked with a full path too so i dont think its that. permissions sounds more likely. what like i said, what rights are missing?
0
 

Author Comment

by:mwoolger
ID: 9730980
then also theres the fact that the batch file runs perfectly locally so how does this mean that there is a disparity between the rights assigned to an invoked command window and that assigned to a command window opened by conventional means?
0
 
LVL 16

Expert Comment

by:_nn_
ID: 9731067
I rather think it's something like : the self extracting creation tool somehow requires (although it apparently doesn not use it) to interact with the desktop and is getting prevented to do so when run in that service context.

Just got a stupid idea : that tool creates a .exe file right ? Are you running some AV on that box ? If yes, did you try to deactivate it ?
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:mwoolger
ID: 9731155
we were running AV but disabling it has made no difference.

my gut feeling is that it looks like its trying to run a gui, just as if a default user was trying to invoke notepad.exe, it would appear in the processes list but never actually appear on screen as it is essentially being run remotely. of course the annoying thing is that it doesnt flick up a gui when running it locally, thereby giving some proof that it needs to interact with the desktop.

0
 
LVL 16

Expert Comment

by:_nn_
ID: 9731212
Is Oracle running under a specific account or is it LocalSystem ?
What version of winzip is this ? I can try to download it and reproduce the phenomenon here.
0
 

Author Comment

by:mwoolger
ID: 9731250
it is winzip self extractor 2.2, but only the licensed version can be run from a batch file silently (unless you crack it of course).
oracle is running under a named account in this instance.

when i did the set command within a command window launched locally, the username environment variable was specified as being the user that was logged onto the win2k server. contrast this with the "Default User" of the remotely launched cmd window and this is the most obvious pointer to permissions etc.

[the batch file will be different each time as well so its a default user setting that needs to be changed rather than an attribute of the batch file]
0
 
LVL 16

Expert Comment

by:_nn_
ID: 9731501
>> it is winzip self extractor 2.2, but only the licensed version can be run from a batch file silently (unless you crack it of course).

Ah. looks like I won't be able to reproduce very quickly... Since it's registered, I could imagine that the executable is looking for the license key in the registry. Possibly it cannot find it when run from that account... At this point, I'd use regmon :
http://www.sysinternals.com/ntw2k/source/regmon.shtml
to try to find out. Start it, set a filter to the executable name of the self extractor, run it from the logged on user and compare against a run in the Oracle context. Maybe you'll be able to see something interesting.
In case the license key is located in a file, use filemon instead :
http://www.sysinternals.com/ntw2k/source/filemon.shtml


I'm sorry to tap in the dark like this, but that's the best I can do for now. Hopefully, an expert having experiencing a similar issue will be able to help more quickly.
0
 

Author Comment

by:mwoolger
ID: 9731805
0
 
LVL 16

Expert Comment

by:_nn_
ID: 9731976
Interesting discussion. You said, you've "done this", but how ? Logged in interactively under that Oracle account or used the indicated procedure with an AT-scheduled cmd.exe ?
0
 

Author Comment

by:mwoolger
ID: 9732049
instead of sending getting oracle (via this c dll) to execute a command "<batch filename>.bat" i did the at command. then on the server at the appropriate time the cmd window came up. in this window i then went and made something into a self extracting exe and lo it brought up a license agreement. i ok'd this and now have the following results:

1) i reran the batch file (via C dll etc) from a SQL session on the server and it went belly up again. just sat there.
2) i accidentally reran batch file (via C dll etc) from the SQl session on my client machine and it worked fine!!!!!!!!!

now this raises an important question: the "user" that is invoking this file - is it ME (ie my oracle username) or is it an "oracle" account. due to (1) this suggests the former (as this was the useraccount that did the AT command to get a window up etc and so from this users perspective has accepted the license agreement).
BUT
does this mean that every individual client machine will have to do this AT command method thingy to start with as a one off when i deliver the software? bizarre or what.

(I'll still give you the points when we've finished hypothesizing)





0
 
LVL 16

Accepted Solution

by:
_nn_ earned 250 total points
ID: 9732180
Well, that's the reason why I was trying to get you using regmon, because that first-time run agreement thingie is most likely stored somewhere in the registry. So, if you can write that key in the correct place at the moment your software is installed, the problem could be avoided altogether. What do you think ?

>> oracle is running under a named account in this instance

I would still try to log in interactively with that account and do the same operation (agreement ok). An AT-scheduled command is suppose to start in the context of the LocalSystem, which may possibly explain the differences you observed between remote and local sql sessions.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article shows how to make a Windows 7 gadget that extends its U/I with a flyout panel -- a window that pops out next to the gadget.  The example gadget shows several additional techniques:  How to automatically resize a gadget or flyout panel t…
What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now