Jump to content

Recommended Posts

Posted

Hello all,

I need a short script that will check if a user profile is present on the local C: drive, and if it is it will then do a task.

 

I was thinking along the lines of:-

 

If exits C:\users\%username% then…….

 

Or

 

If exits “C:\Documents and Settings\%username%” then……

 

But it seems to be falling over with the following error after it is run…..

 

C:\users\student1 was unexpected at this time

 

So the user name is identified but the script stops

 

Any ideas?

 

Thanks

 

John

Posted (edited)

erm how about

 

If not exist C:\path\to\profile goto end

 

Command you want if it does exist

 

End

 

example

 


if not exist C:\user\student goto end 

xcopy C:\user\student \\server\share /d /g /h

end

 

 

just change the xcopy command to whatever you would like to do with it

 

More Info on If command http://www.computerhope.com/if.htm

Edited by glennda
And More info
Posted

Have you just made a typo copying it here? You've used "exits" but you need "exist" (no S at the end; S in the middle)

 

(note if you do move to VBScript then it becomes "fileexists" or "folderexists" - there is an S on the end)

 

Otherwise, I can't see anything wrong with what you've got - it should work

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



  • 158 What is your preferred operating system (PC)

    1. 1. Operating systems:


      • MacOS
      • Windows 10
      • Windows 11
      • Windows Vista
      • ChromeOS
      • Other (reply)

×
×
  • Create New...