0

I've beeen trying to set up a batch-script which should do the following:

First, install a exe file, preferrably quietly (of course check if it's already installed). Then traverse to where .net framework is installed. After the traverse, it should set Caspol rights and regasm. And then copy some shortcuts and a checkfile (to see if this has already been done).

Does anyone have any idea why this is not working? When I do the commands by copy & paste into my commandline, everything works, but not when the script is running.

Suggestions on what is wrong, and some improvements would be greatly appreciated.

REM Upgrade RS Framework 2.0V
@echo off

if exist "C:\CheckNet.txt" GOTO END

P:\RS\Klient\PClient.exe

cd\
cd C:\Windows\Microsoft.NET\Framework\v2.0.50727

caspol -machine -addgroup 1. -url \\Domain\Program\RS\* FullTrust -n RS -s on

regasm \\Domain\Program\RS\TE.HCW.PRS.RS.Wrapper.dll 

copy \\Domain\Program\TE\RS\ClientInstallation\CheckNet.txt c:\
COPY "\\Domain\Program\shortcut\RS\*.*" "c:\Documents and settings\All Users\Desktop"

:END
1
  • 2
    In what way is it not working ? Are there any error messages ?
    – user9517
    Nov 22, 2010 at 10:42

2 Answers 2

3

My guess is you have not explicitly set the drive to 'C:'. It possible that when the script runs it's current working directory is not on the c: drive.

UPDATED: full path to call caspol and regasm

Try this:

REM Upgrade RS Framework 2.0V
@echo off

if exist "C:\CheckNet.txt" GOTO END

P:\RS\Klient\PClient.exe

C:\Windows\Microsoft.NET\Framework\v2.0.50727\caspol -machine -addgroup 1. -url \\Domain\Program\RS\* FullTrust -n RS -s on
C:\Windows\Microsoft.NET\Framework\v2.0.50727\regasm \\Domain\Program\RS\TE.HCW.PRS.RS.Wrapper.dll 

copy "\\Domain\Program\shortcut\RS\*.*" "c:\Documents and settings\All Users\Desktop"
copy \\Domain\Program\TE\RS\ClientInstallation\CheckNet.txt c:\

:END
3
  • isnt that what this specific code does? "c:\ cd C:\Windows\Microsoft.NET\Framework\v2.0.50727" When I copy and paste this into my commandlinewindow, it jumps straight to my .net framework folder.
    – Maclovin
    Nov 22, 2010 at 11:53
  • not if you're on another drive to start with, also you're doing this in your batch file: "cd\ cd C:\Windows\Microsoft.NET\Framework\v2.0.50727"
    – BoyMars
    Nov 22, 2010 at 12:29
  • Thanks for all the help, dudes and dudettes. I have some follow up questions: How do I do the Caspol thing quietly? Right now I get "The Operation you are performing, will change your security policy. Are you really really sure you want to do this? The same goes with the application. Is it possible to get this to run quietly?
    – Maclovin
    Nov 23, 2010 at 7:21
1

If the script cannot find CASPOL or REGASM, then likely the path the script is running under is different than the path the command window is running under. In the command window type set path to see the paths that Windows will search looking for a file. Three ways to fix it: One) update the environment the script runs under Two) Add a set path command to the script to set the path before the CASPOL line. Three) Use the full path on the CASPOL and REGASM something like c:\directorypath\CASPOL ....

4
  • Can you give me an example on how to do this?
    – Maclovin
    Nov 22, 2010 at 17:55
  • Thanks for all the help, dudes and dudettes. I have some follow up questions: How do I do the Caspol thing quietly? Right now I get "The Operation you are performing, will change your security policy. Are you really really sure you want to do this? The same goes with the application. Is it possible to get this to run quietly?
    – Maclovin
    Nov 23, 2010 at 11:19
  • technet says that CASPOL.exe has a -q option that suppresses the prompt temporarily. Haven't tried it myself, but it solve solve your problem.
    – BillN
    Nov 24, 2010 at 23:34
  • What I get if I use -q is the same that I get if I dont use -q. "The operation you are about to perform will change the security policy. Are you sure you want to do this? Yes / No
    – Maclovin
    Nov 26, 2010 at 14:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .