SOLVED: have a look on the later posts
TASK: rename a file called TabletFilter.sys ( its my graphic tablet driver ) because windows 8 (my OS) apps needs an other driver then photoshop for the pin pressure. And I want to write a c++ program that just rename all driver files to .old
The code based on the rename example from cplusplus.com
#include <stdio.h>
int main ()
{
int result;
char oldname[] ="TabletFilter.sys";
char newname[] ="TabletFilter.sys.old";
result= rename( oldname , newname );
if ( result == 0 )
puts ( "File successfully renamed" );
else{
result= rename( newname , oldname );
if( result == 0)
puts ( "File successfully renamed" );
else
perror( "Error renaming file" );
}
return 0;
}
I tried “run as Admin” as well, but I still get
Error renaming file: No such file or directory
what can I do?
EDIT:
The file is definitly in the same folder … i copyed them both there… even at c:\windows\ i tryed it … and i use a manifest
Executable: TabletRenameDriver.exe
Manifest: TabletRenameDriver.exe.manifest
Sample application manifest file:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity version="1.0.0.0"
processorArchitecture="X86"
name="TabletRenameDriver"
type="win32"/>
<description>Description of your application</description>
<!-- Identify the application security requirements. -->
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges>
<requestedExecutionLevel
level="requireAdministrator"
uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
i tryed uiAccess true and false.
Yes I have a problem with the rights
The driver is loaded but iam still able to change his name … dont know why, but its possbile. I tryed it. I want to solve this problem with c++ so pls dont tell me that there are many script languages out there that can handle the problem very well 😉 I know this
Thanks for all your help
I finished my programm and it works perfectly now
note: added "requireAdministrator" uiAccess="false" via VS2012 Settings
With only 48 lines of code … can a script be shorter?PS: Revisiting this post after some time, I think there are quite a few ways to approach this issue differently. However, the main point still stands: If you want to do something like this, you have to run with admin permissions … and maybe use loops, lists/vectors and some proper string manipulation 😛