Jump to content

Recommended Posts

Posted

I am trying to make a batch script that runs on logon, to copy an image file from the server to the C:\. I've gone through a pause after every line, and it gives me no syntax errors, and yet it doesn't do the job I'm asking. The paths are correct for where want to go, and I've tried the mapped path along with the UNC, so any help is appreciated.

 

@echo off

for /f "delims=" %%# in  ('"wmic path Win32_VideoController  get CurrentHorizontalResolution,CurrentVerticalResolution /format:value"') do (
 set "%%#">nul
)

echo %CurrentHorizontalResolution%
echo %CurrentVerticalResolution%
if exist "%CurrentVerticalResolution%" == "1024" goto :ResultTrue 
:ResultFalse
   goto Done
:ResultTrue
XCOPY /y PATH\image.jpg C:\
:Done

Posted

I think the problem is with the line:

 

 

if exist "%CurrentVerticalResolution%" == "1024" goto :ResultTrue 

 

You don't need the word exist. Just make it

 

if "%CurrentVerticalResolution%" == "1024" goto :ResultTrue

 

HTH,

 

Meldrew

Posted
I am trying on my machine, with full admin privileges so thats not an issue, and we're not a school here, its an office, they have their C:\ should they need it (personal drives clone to the C:\ documents incase of hardware failure so that they can still work and vice versa).
Posted
we're not a school here, it's an office

The workplace is irrelevant. UAC will either prevent users from saving files to the root of C:\ or redirect the files to %LOCALAPPDATA%\VirtualStore.

Posted (edited)
The workplace is irrelevant. UAC will either prevent users from saving files to the root of C:\ or redirect the files to %LOCALAPPDATA%\VirtualStore.

 

Create a folder / directory on the root of C: and do what you need inside this folder ??

 

C:\Images

 

????

 

Just saying ....

Edited by mac_shinobi
Posted
The workplace is irrelevant. UAC will either prevent users from saving files to the root of C:\ or redirect the files to %LOCALAPPDATA%\VirtualStore.

 

^ this

 

Try writing the file to an area that all users have read/write access to. Creating files and folders in the root is unlikely to end well. I might suggest ‪C:\Users\Public\Downloads for a save location.

Posted
^ this

 

Try writing the file to an area that all users have read/write access to. Creating files and folders in the root is unlikely to end well. I might suggest ‪C:\Users\Public\Downloads for a save location.

or run it as a pc startup script those run as administrator

  • Thanks 1
Posted
or run it as a pc startup script those run as administrator

 

Actually I was going to reply and point out that this might not align well with "runs at logon" if that's really what the OP needs, but then thinking about it, my first suggestion isn't the greatest solution either depending on what the goal is here...

 

So, if you need this image to be a per machine thing @featured_spectre then go with the suggestion from @sted - it's trivial to make this a task that runs at system start up via GPO or even with a scheduled task ("when the system starts" or suchlike is an option here). I'd still suggest writing to somewhere outside the root, maybe create a folder in programdata to host the images?

 

If you need to to be a per user thing then instead have it run as a user login script and have it write to %temp%, which will write to the designated temporary folder for each individual user (users\%username%\appdata\local\temp IIRC).

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



×
×
  • Create New...