Reputation: 906
I have written some batch files in windows to centralise some calls to other batch files so that I can start up some processes easily, but when run from my central file the processes don't run properly; they need network access and this seems to be denied and I get a load of connection refused exceptions. This is presumably a permissions problem, but I'm not sure how to get round it. I've tried running my script by ricght clicking and choosing 'run as administrator' but this doesn't work properly (my first 'cd...' does not change the directory for some reason, then the calls fail) Is there a way I can imply my permissions to the other processes? My scripts look basically like this:
cd "F:\Applications\Process1"
START "Process 1" runProcess1.cmd
cd "C:\Applications\Process2"
START "Process 2" runProcess2.cmd
Upvotes: 0
Views: 1411
Reputation: 1
Meant as a comment on answered Aug 24 '12 at 14:18 user1111284 But I cannot comment until I get 50 Reputation.
Use "cd/?" to get the short summary of cd command usage.
Use "cd/d" to change the current drive as well as the path.
Change your script like this:
cd/d "F:\Applications\Process1" START "Process 1" runProcess1.cmd cd/d "C:\Applications\Process2" START "Process 2" runProcess2.cmd
I post this to other seekers. The /d option should be better known.
Upvotes: 0
Reputation: 906
It turns out if you try and use 'cd "F:\Applications\Process1"' drive F will switch to the chosen folder, but you won't be switched to drive F. i.e. you will still be at C:\user\username (or whatever the default is) and if you then type 'F:', you will be at 'F:\Applications\Process1'. This meant that I was running two instances of the same process from the same place, when in fact I wanted to run two instances of the same process in different locations, so it looked like ti was launching properly then faailing to get network permissions, but was infact conflicting with itself. To fix this, I chagned my script as so:
F:
cd "F:\Applications\Process1"
START "Process 1" runProcess1.cmd
C:
cd "C:\Applications\Process2"
START "Process 2" runProcess2.cmd
Upvotes: 0
Reputation: 19335
command runas
with option /savecred
should ask for password the first time it runs.
maybe this can help http://www.bellamyjc.org/en/superexec.html,
Upvotes: 1