+ Post New Thread
Page 2 of 2 FirstFirst 12
Results 16 to 23 of 23
Windows 7 Thread, Environment variables GPP in Technical; Fails to run for some reason, is the syntax correct there? EDIT: it doesn't like the %a EDIT2: ok works ...
  1. #16
    mrbios's Avatar
    Join Date
    Jun 2007
    Location
    Stroud, Gloucestershire
    Posts
    2,331
    Thank Post
    327
    Thanked 234 Times in 193 Posts
    Rep Power
    94
    Fails to run for some reason, is the syntax correct there?

    EDIT: it doesn't like the %a

    EDIT2: ok works fine if i run it manually but doesn't run from a script, this is frustrating.

    EDIT3: when running it in a command prompt window manually it runs like this:
    Code:
    C:\>for /f %a in ('C:\GetADAttributes.exe givenName') do for /f %b in ('C:\GetADAttributes.exe sn') do mkdir "C:\%b, %a"
    
    C:\>for /F %b in ('C:\GetADAttributes.exe sn') do mkdir "C:\%b, FIRSTNAME"
    
    C:\>mkdir "C:\LASTNAME, FIRSTNAME"
    the first line is the line i execute, the next two are something it's doing on its own.
    Last edited by mrbios; 8th October 2012 at 02:47 PM.

  2. #17

    Join Date
    Mar 2011
    Location
    Bournemouth
    Posts
    280
    Thank Post
    16
    Thanked 74 Times in 64 Posts
    Rep Power
    21
    Quote Originally Posted by mrbios View Post
    Fails to run for some reason, is the syntax correct there?

    EDIT: it doesn't like the %a

    EDIT2: ok works fine if i run it manually but doesn't run from a script, this is frustrating.

    EDIT3: when running it in a command prompt window manually it runs like this:
    Code:
    C:\>for /f %a in ('C:\GetADAttributes.exe givenName') do for /f %b in ('C:\GetADAttributes.exe sn') do mkdir "C:\%b, %a"
    
    C:\>for /F %b in ('C:\GetADAttributes.exe sn') do mkdir "C:\%b, FIRSTNAME"
    
    C:\>mkdir "C:\LASTNAME, FIRSTNAME"
    the first line is the line i execute, the next two are something it's doing on its own.
    If i copy and past that into a command prompt exactly as is it work fine, creating a folder in my C drive called "Miles, Chris".

  3. #18
    mrbios's Avatar
    Join Date
    Jun 2007
    Location
    Stroud, Gloucestershire
    Posts
    2,331
    Thank Post
    327
    Thanked 234 Times in 193 Posts
    Rep Power
    94
    Quote Originally Posted by ChrisMiles View Post
    If i copy and past that into a command prompt exactly as is it work fine, creating a folder in my C drive called "Miles, Chris".
    That's precisely what i get though, copying it into a command prompt works fine. Try sticking it in a .bat file and it won't as the batch file only runs the first line and forgets about the second two that are manually created in an open command prompt.

  4. #19

    Join Date
    Mar 2011
    Location
    Bournemouth
    Posts
    280
    Thank Post
    16
    Thanked 74 Times in 64 Posts
    Rep Power
    21
    Quote Originally Posted by mrbios View Post
    Fails to run for some reason, is the syntax correct there?

    EDIT: it doesn't like the %a

    EDIT2: ok works fine if i run it manually but doesn't run from a script, this is frustrating.

    EDIT3: when running it in a command prompt window manually it runs like this:
    Code:
    C:\>for /f %a in ('C:\GetADAttributes.exe givenName') do for /f %b in ('C:\GetADAttributes.exe sn') do mkdir "C:\%b, %a"
    
    C:\>for /F %b in ('C:\GetADAttributes.exe sn') do mkdir "C:\%b, FIRSTNAME"
    
    C:\>mkdir "C:\LASTNAME, FIRSTNAME"
    the first line is the line i execute, the next two are something it's doing on its own.
    Does it create a folder at all? Can you paste your script exactly as is?

  5. #20

    Join Date
    Mar 2011
    Location
    Bournemouth
    Posts
    280
    Thank Post
    16
    Thanked 74 Times in 64 Posts
    Rep Power
    21
    OK it doesnt work for me in a batch file either.... let me look at it.

  6. Thanks to ChrisMiles from:

    mrbios (8th October 2012)

  7. #21

    Join Date
    Mar 2011
    Location
    Bournemouth
    Posts
    280
    Thank Post
    16
    Thanked 74 Times in 64 Posts
    Rep Power
    21
    OK stupid problem, in a batch file you have to escape the variables like this:

    Code:
    for /f %%a in ('GetADAttributes.exe givenName') do for /f %%b in ('GetADAttributes.exe sn') do mkdir "C:\%%b, %%a"

  8. Thanks to ChrisMiles from:

    mrbios (8th October 2012)

  9. #22
    mrbios's Avatar
    Join Date
    Jun 2007
    Location
    Stroud, Gloucestershire
    Posts
    2,331
    Thank Post
    327
    Thanked 234 Times in 193 Posts
    Rep Power
    94
    Quote Originally Posted by ChrisMiles View Post
    OK stupid problem, in a batch file you have to escape the variables like this:

    Code:
    for /f %%a in ('GetADAttributes.exe givenName') do for /f %%b in ('GetADAttributes.exe sn') do mkdir "C:\%%b, %%a"
    *FACEPALM* sorry it's been a long day, works now haha

    Thanks for all your help Chris, you've been fantastic, next on my agenda i need to make some sort of system for moving all files from location 1 to location 2 and renaming them all to include XXXX_ at the beginning of each file name ............ but that's a job for tomorrow lol

    EDIT: oh..i'd forgotten about the fun part that is the login scripts, even though we have something working when run from the desktop, i now need to get it working when run on logon, which currently it doesn't appear to EDIT AGAIN: didn't appear to because i was being stupid, works fine now
    Last edited by mrbios; 8th October 2012 at 03:43 PM.

  10. #23

    sonofsanta's Avatar
    Join Date
    Dec 2009
    Location
    Lincolnshire, UK
    Posts
    4,467
    Thank Post
    750
    Thanked 1,210 Times in 852 Posts
    Blog Entries
    45
    Rep Power
    533
    FWIW, you can run programs at logon without using a script by GPO: user config > policies > admin templates > system > logon > run these programs at user logon. Has the advantage of launching the program once the desktop is shown, so doesn't slow logon times down; I actually use it to run a VBS, still, but one that takes ten seconds and hangs logon at "preparing your desktop" if it's run as a logon script.

  11. Thanks to sonofsanta from:

    themightymrp (8th October 2012)

SHARE:
+ Post New Thread
Page 2 of 2 FirstFirst 12

Similar Threads

  1. adding Environment Variables?
    By GiantEnemyAnt in forum Scripts
    Replies: 7
    Last Post: 11th August 2009, 08:17 PM
  2. application data Environment variables redirect
    By ful56_uk in forum Wireless Networks
    Replies: 14
    Last Post: 27th July 2009, 10:23 PM
  3. Environment Variables Again
    By Reaper in forum Scripts
    Replies: 2
    Last Post: 19th February 2009, 04:45 PM
  4. Batch: Text file -> Environment variable?
    By PiqueABoo in forum Scripts
    Replies: 5
    Last Post: 13th December 2006, 11:09 PM
  5. Environment variables or other method
    By HodgeHi in forum Scripts
    Replies: 3
    Last Post: 21st June 2006, 09:05 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •