featured_spectre Posted December 19, 2014 Posted December 19, 2014 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
Meldrew Posted December 19, 2014 Posted December 19, 2014 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
Arthur Posted December 19, 2014 Posted December 19, 2014 Standard users also won't have permission to save files to the root of the C:\ drive.
featured_spectre Posted December 19, 2014 Author Posted December 19, 2014 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).
Arthur Posted December 19, 2014 Posted December 19, 2014 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.
mac_shinobi Posted December 20, 2014 Posted December 20, 2014 (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 December 20, 2014 by mac_shinobi
Roberto Posted December 20, 2014 Posted December 20, 2014 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.
sted Posted December 20, 2014 Posted December 20, 2014 ^ 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 1
Roberto Posted December 20, 2014 Posted December 20, 2014 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).
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now